On Github akhilstanislavose / pry-presentation
August 4, 2012 akhil stanislavose - akhil@mobme.in
Pry is a powerful alternative to the standard IRB shell for Ruby.
def my_method
  # some super code
  # break point
  binding.pry
  # more super code
end
            
          
# cd into a module, class, or an object.
[1] pry(main)> cd String
[2] pry(main)> cd Enumerable
[3] pry(main)> cd "Hi, I am a String object"
# ls the current context
[4] pry(String)> ls
# list only sigleton instance methods
[5] pry(String)> ls -qm
            
          
# Search for a method
[1] pry(main)> find-method method_name [Scope]
# Get documentation for a method/class/module
[2] pry(main)> show-doc String::tabelize
[3] pry(main)> stat String::tabelize
# Show source of a method/class/module
[4] pry(main)> show-source String::tabelize
            
          
# Show the input buffer
[1] pry(main)> show-input
# Edit a line in input buffer
[2] pry(main)> amend-line [line_no|startln..endln] new line
# Delete a line in input buffer
[3] pry(main)> amend-line line_no [line_no|startln..endln] !
# Fire up your editor to enter long code in to console
[4] pry(main)> edit
# Show history
[4] pry(main)> history [--tail | --head | --replay]
            
          
# exectue any commad in shell from pry
[1] pry(main)> .<any-shell-cpmmand>
[2] pry(main)> .ls
# String interpolation in shell commands
[3] pry(main)> .cd #{dir_path}
# PRYs own cat with syntax highlight for source files
[4] pry(main)> cat source.rb
# Use shell-mode to make your prompt more like you shell prompt
[4] pry(main)> shell-mode
            
          (Questions ?)