Debugging

Summarized using AI

Prying Into Your App's Private Life

Corey Woodcox • August 16, 2012 • Earth

In this presentation, Corey Woodcox discusses the Ruby REPL Pry at the MountainWest RubyConf 2012. He begins by expressing his nervousness as this is his first presentation and shares his background in the Ruby community. The focus of the talk is on explaining what Pry is and how it compares to IRB, another Ruby REPL. Corey outlines several key features of Pry that enhance the development experience:

  • Definition and Functionality of REPL: Corey defines REPL (Read, Evaluate, Print, Loop) and mentions various examples including IRB and CoffeeScript.
  • Pry vs. IRB: While IRB has its merits, Corey highlights that it is not sufficient for all needs. Pry addresses these limitations with its additional features.
  • Shell Access: One significant feature of Pry is easy shell access. Developers can run shell commands directly within Pry, which simplifies the workflow.
  • Object Browsing: Pry allows users to browse objects and directories, making it easier to interact with and understand their application's structure.
  • Integration with Gist: Corey talks about the ability to share snippets of code quickly. By using the Gist gem, developers can paste methods directly from their Pry session into Gist for sharing or help.
  • Replacing IRB with Pry: Corey provides instructions on how to replace IRB in a Rails console with Pry, enhancing the usability of the Rails console significantly.
  • Real-world Example: He shares a personal anecdote about a debugging scenario in which Pry helped him identify a complex problem caused by monkey-patching in Ruby—showing how Pry can simplify troubleshooting.

Corey concludes the talk with insights into the advantages of implementing Pry within development environments and encourages attendees to leverage its features effectively. His enthusiasm for live coding and interaction suggests a dynamic approach to learning and utilizing new tools in Ruby development.

Prying Into Your App's Private Life
Corey Woodcox • August 16, 2012 • Earth

Help us caption & translate this video!

http://amara.org/v/FGiJ/

MountainWest RubyConf 2012

00:00:15.040 All right, my name is Corey. I don't know if you can tell, but this is my first presentation. It's the first time I've ever done this in my life, so it's slightly terrifying.
00:00:30.400 I saw the commission on the MWRC website that said, 'Come hang with the smartest Rubies in the world.' I will be the first to tell you that I am definitely not one of those. I work at Saxonhorn Advertising, where we do advertising websites and other services for a bunch of car dealerships and fun things like that. I really love Ruby and the community. Mike and David were talking earlier about the community, and I wouldn't have the job that I have right now without the Utah Ruby review group. I don't know where I would be without all the fabulous people in the community.
00:01:15.280 But the most important thing you should know about me is that I have absolutely no idea what I'm doing. I've never done this before. As I was submitting the proposal and they accepted it, they told me they weren't sure if I would be able to cover 30 minutes. Yet, they still chose me.
00:01:46.799 So, what is Pry? Pry is a Ruby REPL. How many of you know what a REPL is? Okay, that’s not bad. When I first saw the screencast by Josh Cheek about Pry, he used that phrase 'REPL,' and I had no idea what it was, so I was a little confused. Basically, it stands for Read, Evaluate, Print, and Loop. It's a three-step loop of read, evaluate, and print. For example, we have IRB, which is one of those REPLs.
00:03:14.000 CoffeeScript also has one; if you run it without arguments, it turns into a little console. PHP has one as well, but I wouldn't recommend it. How many of you know what IElm stands for? Anyone? I have it in my speaker notes, but unfortunately, I can't see them because my phone is acting up. Oh, yes! It stands for Inferior Emacs Lisp Mode.
00:04:04.560 The Chrome JavaScript console is another good example. Basically, anything that has a console can be considered a REPL. We have IRB, and it’s awesome. I think these slides are out of order, but we already have one. Why do we need another one? Well, that's simply not true. IRB is not the end-all, be-all, because it really doesn’t suck. If you guys have ever used IRB tools, it's fantastic! I discovered it a couple of weeks ago while preparing this, and it does a lot of cool things. In fact, many of them integrate nicely with Pry.
00:05:51.600 I implemented IRB tools in one of my projects at work. Then, when I switched to a different project where I didn't have it, I immediately noticed it was missing when I was in the console. Essentially, IRB, by itself, doesn't do much.
00:06:46.160 Pry has many features that make it really awesome. For example, it provides easy shell access. So, anytime you’re working in Pry and want to execute a shell command, you just put a dot before the command. It magically runs that command for you and allows you to fire up an editor or any command you want right there.
00:07:51.200 You can also do object browsing as if you were in a shell or browsing directories in your terminal. For instance, you can execute an 'ls' command after changing directories into your application's controller, which lists all available items. It enables you to browse the source and can be incredibly helpful.
00:08:45.920 This got me out of a really tight situation once while working with a Ruby gem. We had an issue with a conditional association in my Rails model that wouldn't load. Through Pry, I discovered that Ruby was monkey-patching the String class and adding a 'to_proc' method. This issue caused significant headaches, but with Pry, I could clearly see where the problem was and what it did.
00:09:44.160 Pry's integration features are really cool. I love using GitHub and Gist to share snippets of code or get help from friends. You can quickly publish any method to a Gist and share it with someone else for assistance. It requires that you have the Gist gem installed, but once you do, you can paste any method straight into Gist from your session.
00:10:47.920 So, we're going to take some time to play around with this because I love live coding. Okay, you convinced me. If there's nothing useful over there, that sounds like a great idea.
00:11:59.680 That's the biggest takeaway I have. We’ll skip a couple of slides because it’s a long presentation, but one of the most useful features I've found with Pry is that you can replace IRB in your Rails console with it, and it's very straightforward. You can open up your development environment and replace it with Pry using just four lines of code.
00:12:40.520 You simply require Pry, replace IRB with Pry, and once that's done, you can access features that enhance your development experience greatly. Not only can you run commands in the console, but you can also easily execute and test modifications in your app.
00:13:53.200 I had to rush through some of this because I missed my train— a bad habit. Does anyone have any questions?
00:14:07.279 I've used it in some Rails 2 projects, but I can't remember which ones worked, and it didn't always operate as expected. Certain colorization and features in gem dependencies sometimes cause conflicts. If you're using older applications, those dependencies may not work either.
Explore all talks recorded at MountainWest RubyConf 2012
+11