
Tossing Out IRB for Pry - philaquilina
http://www.philaquilina.com/2012/05/17/tossing-out-irb-for-pry/
======
cirwin
One of the coolest things about pry is how it doesn't need to monkey-patch
Object in order to add custom functionality. The command-system stands above
the ruby level.

------
riffraff
just a note, irb always supported something like pry's "cd", through
pushws/popws. This does not make pry less awesome.

~~~
DavidAbrams
Too bad a search on "IRB" turns up mainly "institutional review board."

------
banister
Pry also has a bunch of plugins available including smalltalk-like error
consoles and multi-user remote debugging sessions. See here for more info:
[http://banisterfiend.wordpress.com/2012/02/14/the-pry-
ecosys...](http://banisterfiend.wordpress.com/2012/02/14/the-pry-ecosystem/)

------
theDoug
About half of our developer group has made the change in the last month and
everyone seems to love it.

There's a brief Railscast on it as well:
<http://railscasts.com/episodes/280-pry-with-rails>

------
LordIllidan
Are you by any chance Maltese, or do you have Maltese parents? Just deducing
from your last name and the 8 pointed flag favicon for your blog.

~~~
philaquilina
Good eye! I am indeed half maltese. Although atheist, I've always subscribed
to the (secular) symbolism of the the 8 points on the cross, so I thought it a
good symbol for the site.

~~~
LordIllidan
Well, I am Maltese myself, so it was a surprise to see another Maltese on
hackernews. Props!

~~~
dylanvee
Half Maltese here too!

------
jnovek
This looks really nice, but what I would like even more would be to just jump
out into a minimal multi line edit mode between the "def" and "end" of a
method.

~~~
petepete
In IRB I use flyrb[1], which gives me methods called vi, emacs and mate, that
give me this functionality.

Incidentally, because I want syntax-highlighting for ruby, I have this in my
~/.irbrc

    
    
      def vim
         edit_interactively("vim -c 'set ft=ruby'")
      end
    

[1] - <https://github.com/jtrupiano/flyrb>

~~~
banister
Pry has this functionality built-in but souped-up on a diet of crack:
<https://github.com/pry/pry/wiki/Editor-integration>

;)

~~~
petepete
Ok. I've switched, was surprisingly easy to integrate with Rails too.
Excellent stuff - thanks!

------
dhugiaskmak
Question:

    
    
      [19] (pry) main / Pry: 1> cd ..
      [20] (pry) main / Pry: 0>
    

Shouldn't 'cd..' take you out of the Pry scope?

~~~
philaquilina
Ha yea, there's a typo there. The gist is cached by the wordpress plugin.
Going to fix it at lunch.

Should look like this: [20] (pry) main: 0>

------
iamgilesbowkett
This looks great, but the edit feature is not actually something you can't
have in IRB. Both my own utility_belt gem from 2007 and another person's
sketches gem from 2009 enabled the same functionality.

I think Pry is great, I wrote a little console with it recently for a simple
back-end app, and the edit feature looks like your most advanced option for
this kind of thing. But for the sake of accuracy, it's not actually 100% brand
new functionality. A lot of people have been doing that in IRB for a long
time.

~~~
banister
The Pry editor feature can do a few things that are impossible in IRB (but
correct me if i'm wrong) --- you can call up an editor in the MIDDLE of an
incomplete expression, this is only possible because Pry commands are not
methods - see here: [https://github.com/pry/pry/wiki/User-Input#wiki-
Edit_input_b...](https://github.com/pry/pry/wiki/User-Input#wiki-
Edit_input_buffer)

Other things the Pry editor feature can do that i haven't seen elsewhere: it
can edit methods (`edit-method MyClass#my_method`), it can open up an editor
directly on the file/line that caused the last exception (`edit --ex`), it can
edit previous expressions (`edit -i EXPR`).

Your interactive_editor gem was inspiration for this though, a very nice
little gem :)

~~~
iron_ball
Another approach to editing your code while working in the REPL is to simply
send code from your editor to the browser. I recently wrote a blog post about
setting vim up for this: [http://alanmacdougall.com/blog/2012/03/27/using-vim-
slime-wi...](http://alanmacdougall.com/blog/2012/03/27/using-vim-slime-with-
pry-for-repl-perfection/)

------
alttag
Nice and all, but I clicked the link wondering why Institutional Review Boards
were being tossed, seeing as how they're required by federal law to oversee
ethics in research at publicly funded universities.

~~~
sciurus
Context clues.

If I was in a sportsbar and heard someone dissing the NFL, I wouldn't think
"What do they have against the National Forensics League?"

On HN, if you see an acronym where it doesn't make sense to you, great! Most
likely you're being presented the opportunity to learn about some cool
technology.

~~~
alttag
I did (learn something), but not knowing what "Py" was, there were no other
context clues in the headline. HN is friendly to researchers too, so the
setting is appropriate for the other interpretation of the acronym (and makes
the football analogy mildly condescending).

~~~
lobo_tuerto
But accurate.

