Live and Let Pry

Pry is a read-eval-print-loop (REPL) that can be used as an IRB replacement. It has a smooth, bash-like interface for navigating objects in your running application. It also has an extensible plugin system. I’ve written about pry before on this blog. Over the last few months, I’ve found a few new nuggets of pry goodness that I’d like to share.

Pry has great support for plugins. A quick query on rubygems.org will show you a list. (I find this list to be more inclusive than the one on Pry’s wiki.) Here are some of the plugins that I’ve found most useful.

pry-rails

Replaces the rails console with a pry session.

pry-remote

Connects to Pry remotely using DRb. This is very useful for Rails development. I’ve found myself using this a lot for things like development servers running in fore or code running in my capybara tests. Recently, I’ve used pry-remote to send commands over from a guard to do live code reloading. It really helps on the turn-around time when tweaking values and behaviors in a game (but that’s another post entirely).

pry-debugger

Combines pry with debugger. Adds step next and continue commands to control execution.

pry-doc

Lets you browse Ruby source (including C) directly from the console.

pry-coolline

Takes advantage of the new stdlib io-console library to provide live syntax highlighting for user input. A nifty little Readline replacement.

pry-syntax-hacks

Hacks in special syntax for easily accessing instance variables and private methods.

jazz_hands

This gem packages many of the more useful pry plugin gems together with pry for a one-stop-shop addition to your Gemfile.

Pry is still amazing. With more plugins being developed each day, what are you waiting for?

Conversation
  • Mon ouïe says:

    Also see pry-theme, which allows to pick colors from a 256-color palette to create other themes for syntax highlighting.

  • Shawn Anderson Shawn Anderson says:

    Thanks Mon ouïe,
    I’ll be installing pry-theme today to give it a whirl.

  • Comments are closed.