pry-full
Get up and going with a good set of pry tools right away.
Dependent Gems
Like its bigger, 1.9 brother pry-debugger, allows basic stepping
-
Making the basic "require'pry';binding.pry" from a script come alive.
-
In conjunction with pry-rescue, to explore failing tests.
-
Following calls into other libs.
Provides Pry.rescue do … end
to capture any exceptions and start pry from the context of the source of the exception.
-
Shortens write-run-debug cycles when exceptions are involved.
-
Specifically, RSpec integration. https://github.com/exad/zu/blob/master/spec/spec_helper.rb#L15
-
Exploring causes of hard-to-replicate exceptions.
Starts Pry, listening on a socket, that you can then connect to.
-
Debugging odd glitches, like ones that only occur in production.
-
Cases like with pry-remote but where encryption/auth is needed.
-
…TODO: fill this list out
Allows you to look into the Ruby builtin classes with the ? and $ commands.
-
? [].pop
-
$ [].pop
-
…etc.
An alternative printing style. A little funky, but more detailed than default Pry, especially for complex objects.
-
Compare the output of the large
_pry_
object with and without this. -
Array indices are shown, so you can enter them in the next REPL line.
-
If you want to see the old output, you can
obj.inspect
Method-level git commands.
- Blame/diff a specific method.
Reformat strings with pretty-printing. Auto-detects JSON/XML/Ruby.
-
After a method produces ugly XML, do ">>" by itself to see it prettied.
-
Pass in the string as an arg, e.g., >> '{"a":1}'
-
Pass in any Ruby as an arg, >> File.read("/var/www/foo.html")
Alternative syntax highlighting.
-
Being more snazzy
-
Making pry more like your editor, so you can scan more easily.
A very simple, but nice, plugin. Turns 12345689 into 12_345_689 on output (Which is legal Ruby input). Note that this currently gets hidden with the awesome_print output.
- Any time you have big numbers.
Cirwin's wild bag of tricks. The caveat is that it's pretty wild and tricky. Especially since input with @
s can get rewritten as an instance_variable_get. Still, this is only a matter of understanding the dialect used, and adapting accordingly.
-
Direct member access; User.new.@secret_password
-
Calling private methods; User.new.!hash_password('foo')
-
Accessing Pry outer bindings; cd (a = Object.new) then puts ../a
Other tips
As an alternative to bundle open somegem
, there's this cool sequence:
gem-cd somegem
.zsh
This will drop you into a temporary shell in the install dir of the gem, where
you can use ack
and cat **/* | vim - +setf\ ruby
and other familiar tools
to explore new codebases.