Some Pry
Features
@yannvery
IRB is great to experiment
Pry is more
1 - Basics
ls - list methods
? - show documentation
$ - show source code
2 - History
[4] pry(main)> hist
1: (0..5).each do |number|
2: puts number
3: end
2 - History - replay
[5] pry(main)> hist --replay 1..3
0
1
…
2 - History - all
[35] pry(main)> hist --all --tail 100
Use --all option to list all pry history
[6] pry(main)> def fullname
[7] pry(main)> [first, last].compact.join(' ')
[8] pry(main)> edit
3 - Editor
3 - Editor
3 - Editor
[9] pry(main)> fullname('John', 'Doe')
=> "John Doe"
3 - Editor
configure your editor
edit .pryrc file
Pry.config.editor = 'subl -w'
4 - Copy to clipboard
gem install gist
[9] pry(main)> clipit fullname
Copied content to clipboad!
5 - Reload
# Ruby
load 'lib/user.rb'
#Rails
reload!
with IRB
5 - Reload
[1] pry(main)> user = User.last
[2] pry(main)> edit user
with PRY
5 - Reload
with PRY
[1] pry(main)> user = User.last
[2] pry(main)> edit user
[2] pry(main)> user.fullname
=> "John Doe"
5 - Reload
with PRY
Questions ?!
Pry
• https://github.com/pry/pry/wiki
Yann VERY (@yannvery)
• http://ribium.com

Some Pry Features