Throwing Out IRB for Pry
This week I spent some time learning how to use Pry. For those of you who haven’t tried this wonderful alternative to IRB. spend two hours with it. You’ll never go back. I won’t be hitting on all the features Pry has to offer (because there are plenty). just the ones that immediately jumped out as useful to me. Pry has some of the best documentation and one of the friendliest, canada goose retailers in pei outlet . most helpful IRC channels out there so if you want more in-depth coverage. go check them out.
Without further ado discount buy canada goose outerwear outlet online .
$ gem install pry
I can’t tell you how many times I’ve started to write out a quick hit method in IRB. only to accidentally typo something and then hit enter. Frustration at these moments knows no bounds. But Pry offers a couple nifty solutions. (Note that your prompt may look a little different since I’ve added Pry buy canada goose outerwear outlet online . config buy canada goose outerwear outlet online sale . prompt = Pry buy canada goose outerwear outlet online .. NAV_PROMPT to my pryrc file to give me a little more information. )
There’s a few pretty cool things going on here so let’s break it down.
First notice the on the left side. This is called the expression number. Simply put. it keeps track of what expression you’re on and it won’t change until you’ve completed the current expression. which in our case. is when I finish the method definition with an end statement.
And just like that where to buy buy canada goose outerwear outlet online . we fixed up our bugged method buy canada goose outerwear outlet online .
A very neat alternative to this is the edit command buy canada goose outerwear outlet online sales .
What if you want to edit a method that you worked on at an earlier stage in your Pry session. The edit-method command will help you out there.
Now we get to some very interesting features, canada goose women's tundra down pant store . Pry offers you the ability to “cd” into different scopes. Once we’re in there we can do all sorts of stuff.
There are a few additional plugins you can add to Pry’s repertoire of usefulness. I’ve only started to scratch the surface on these ones but they’re worth mentioning for you to check out yourself.
After you’ve installed the gist gem. you have access to the gist command inside of Pry. As the name might imply. this allows you to gist code up to your github account.
require 'pry' class DebugThisShiz def creepy_critters_in_your_code mixed_array = [ "dung beetle". "praying mantis". 5 ] binding. pry # <- Pry session will be invoked here mixed_array. inject memo. obj end end
Pry now offers an integrated Rails plugin that defaults rails console to Pry instead of IRB, real canada goose homme chateau parka . while still offering the full Rails environment canada goose parka banff paris 2015 . For Rails 3 and up. just add this line to the gemfile.
gem 'pry-rails'.. group =>. development
After a bundle install. you’re good to go canada goose jackets cheap toronto store . Without the plugin. the process is a slightly more difficult (slightly). Check out this page for more info.
You can use ri inside of Pry just like you can from the command line for all your offline documentation goodness most popular canada goose jacket .
I’ve been using Pry for a few months now but only on a very topical level. Spending just a few hours this week plumbing the depths of Pry has brought my effectivity in the REPL. and I’d even argue Ruby. up quite a bit. I love every bit of this tool and the maintainers do an excellent job reaching out and listening to the community buy canada goose foxe bomber 2015 . Within minutes of first joining the IRC channel. John Mair (aka banisterfiend) welcomed me with a warm hello and asked me if I had any questions. Within a few hours. John had me create my first github issue for a feature request. A huge thank you to him and his fellow maintainers for this project and all the questions I had for those kind folks buy canada goose outerwear outlet online . Thanks.