Skip to content

Instantly share code, notes, and snippets.

@lgmkr
Forked from rondale-sc/gist-1.sh
Created July 25, 2012 10:00
Show Gist options
  • Save lgmkr/3175398 to your computer and use it in GitHub Desktop.
Save lgmkr/3175398 to your computer and use it in GitHub Desktop.
give-it-a-pry
# In a rails app
pry(main)>.ls
Capfile Gemfile.lock Rakefile config db lib public test vendor
Gemfile README.md app config.ru doc log script tmp
pry(main)> file_path = '~/.pryrc'
=> "~/.pryrc"
pry(main)> .ls #{file_path}
# /Users/jjackson/.pryrc
pry(main)> cd Article
pry(Article)>ls -mj --grep validate #many options here (--help to learn more), this one will list all singleton methods and search for validate methods
#=> _validate_callbacks
### at any point call 'nesting' to get an overview of where you are at.
pry(main)> nesting
# =>
# Nesting status:
# --
# 0. main (Pry top level)
# 1. Article
pry(main)>cd Pry
pry(Pry)>show-method run_command
# =>
# Number of lines: 4
#
# def run_command(val, target = binding_stack.last)
# process_line(val, "", target)
# Pry::CommandContext::VOID_VALUE
# end
# in ~/.pryrc
Pry.config.editor = "mate"
# then you can simply type
pry(main)> edit -t # opens temp-file in TextMate
pry(main)>cd Pry
pry(Pry)>edit-method -m run_command
# File will open in your editor to line 156 of pry_class.rb ^_^
# gist-method options
# -m, --method Gist a method's source.
# -d, --doc Gist a method's documentation.
# -p, --private Create a private gist (default: true)
# -h, --help This message
pry(Pry):1> gist-method run_command
#=> Gist created at https://gist.github.com/1277098
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment