8. Pry can be configured by a .pryrc file
~/.pryrc
./.pryrc
Project level pryrc files are especially useful
when paired with custom commands
PRY-CUSTOM
9. Almost everything in pry is configurable
Some configuration can even be
modified at runtime via _pry_.<config>
Of particular importance/interest:
Editor
Command prefix
Custom commands
BASIC CUSTOMIZATIONS
10. When using „edit‟ pry uses this setting
If editor is not set, Pry defaults to nano
You can set editor to a proc which
accepts 2 params: file and line
E.g. for sublime text:
EDITOR
12. COMMAND PREFIX
A more permanent solution
Pry.config.command_prefix = „%‟
Now all pry commands must be prefixed
with „%‟
13. CUSTOM COMMANDS
Pry also allows you to define your own
custom commands
By block or class
Useful for often repeated code that
shouldn‟t be checked in
15. CUSTOM COMMANDS
Programmers are lazy (in a good way)
We like our code DRY and expressive
Where is that laziness when it comes to
the console?
Pry + custom commands = DRY,
expressive console
16. Any gem whose name fits the format pry-
<plugin> is a plugin
Beware: these gems are auto-loaded by
pry
--no-plugins option will skip auto-loading
.pryrc files get loaded before plugins
Plugin specific suppression:
Pry.plugins[“debugger”].disable!
PRY-ECOSYSTEM (PLUGINS)
17. Pry-debugger
Works only in MRI 1.8 – 1.9
Pry-byebug
A fork of pry-debugger
Works in MRI 2.0 – 2.1
Pry-nav
Pure ruby implementation
Works on all rubies
DEBUGGERS
18. Pry-stack-explorer
Gives pry commands: up, down, frame, and show-
stack
Pry-rescue (Pry-exception_explorer has been
deprecated)
Allows you to rescue from exceptions into a pry
session
Rescue for entire program, or only for specified
blocks
Plymouth
Jump into a pry session on test failure
WHEN THINGS BREAK
19. Uses regex magic to add some easy-access
syntax hackery
Accessing instance variables
foo.@instance_var
Calling private methods
foo.!private_meth()
Examining things in parent pry sessions
puts ../local_var
Just be careful with your regexes
PRY-SYNTAX-HACKS
20. Pry-doc
Adds core ruby class documentation for “?” and
“$” commands
Pry-vterm_aliases
Makes your ZSH and Bash aliases available to
pry‟s .<shell> command
Pry-theme
Color themes for pry‟s syntax highlighting
MISCELLANEOUS PLUGINS
21. Pry-rails
Turns rails console into a pry session
Teaches Pry new commands
show-[middleware|model|models|route]
recognize-path
Pry-plus
A pre-packaged group of useful plugins
INTEGRATION
22. Puts is ok. But don‟t hesitate to drop back and
use the big guns
REPL driven programming is incredibly powerful
Especially when working with new code/library
Explore code
Bundle open your favorite gem when it bugs out (or
just cd into it)
You never know what you‟ll find
CONCLUSION
Editor's Notes
Let’s be honest. The vast majority of the time, “puts the_thing_that_makes_no_sense” is completely sufficient to figure out what’s going wrong in your programI don’t believe that we spend 60% of our time debugging the kinds of problems that can be solved with a puts
Also, these are useful
Some plugins like the debuggers hook into the Pryinit process so using pryrc suppression won’t always save the day.
Demonstration of bug running ./todo.rb items buggy_list