pry at the ruby drink-up of sophia, february 2012
DESCRIPTION
Presented at the Ruby Drink-up of Sophia Antipolis on the 7th of February 2012 by Philippe Antras (@_philant_).TRANSCRIPT
![Page 2: Pry at the Ruby Drink-up of Sophia, February 2012](https://reader031.vdocuments.site/reader031/viewer/2022020207/55959eb71a28ab622d8b4627/html5/thumbnails/2.jpg)
Pry
REPLCan be invoked at runtimeObject explorationSource and documentation accessShell command executionGist integration - not shown todaySyntax highlighting, completionExtensible: plugin, commands - not shown todayRemote session with pry-remote gem and DrB
http://pry.github.com
![Page 3: Pry at the Ruby Drink-up of Sophia, February 2012](https://reader031.vdocuments.site/reader031/viewer/2022020207/55959eb71a28ab622d8b4627/html5/thumbnails/3.jpg)
> gem install pry
![Page 4: Pry at the Ruby Drink-up of Sophia, February 2012](https://reader031.vdocuments.site/reader031/viewer/2022020207/55959eb71a28ab622d8b4627/html5/thumbnails/4.jpg)
Some Pry commands
show-docshow-methodhistory
play -f <file>
edit <file>edit [input buffer]
ri Array#each
space to escape command:pry(main)> cat = "fido"
<your commands here>
To get a list of all commands:Pry(main)> help
![Page 5: Pry at the Ruby Drink-up of Sophia, February 2012](https://reader031.vdocuments.site/reader031/viewer/2022020207/55959eb71a28ab622d8b4627/html5/thumbnails/5.jpg)
Pry interactions
● ;● !● edit● <space>● _ <underscore>● history ● history --replay 101..105
![Page 6: Pry at the Ruby Drink-up of Sophia, February 2012](https://reader031.vdocuments.site/reader031/viewer/2022020207/55959eb71a28ab622d8b4627/html5/thumbnails/6.jpg)
shell commands
Pry assumes commands prefixed with a dot are shell commands
pry(main)> .ls -lpry(main)> .svn update
pry(main)> .cat #{temp_file}
pry(main)> shell-mode #limited completion
![Page 7: Pry at the Ruby Drink-up of Sophia, February 2012](https://reader031.vdocuments.site/reader031/viewer/2022020207/55959eb71a28ab622d8b4627/html5/thumbnails/7.jpg)
Object explorationpry(main)> pry-versionPry version 0.9.7.4 on Ruby 1.8.7pry(main)> cd Prypry(Pry)> lspry(Pry)> cd @historypry(Pry)> ls -mpry(Pry)> show-doc savepry(Pry)> show-method savepry(Pry)> filename = 'history'pry(Pry)> save filenamepry(Pry)> .cat #{filename}pry(Pry)> cd @historypry(Pry::History)> p sizepry(Pry::History)> puts sizepry(Pry::History)> nestingpry(Pry::History)> cd ../..pry(main)
![Page 8: Pry at the Ruby Drink-up of Sophia, February 2012](https://reader031.vdocuments.site/reader031/viewer/2022020207/55959eb71a28ab622d8b4627/html5/thumbnails/8.jpg)
debugging with Pryruntime invocation
binding.pry
<object>.pry
whereami
![Page 9: Pry at the Ruby Drink-up of Sophia, February 2012](https://reader031.vdocuments.site/reader031/viewer/2022020207/55959eb71a28ab622d8b4627/html5/thumbnails/9.jpg)
Documentation and source browsing
install the pry-doc plugin:> gem install pry-doc
pry(main)> a = [1, 2, 3]pry(main)> ls a -mpry(main)> show-doc a.nitems pry(main)> ls Array -Mpry(main)> show-doc Array#shelljoin pry(main)> show-method Array#shelljoin
![Page 10: Pry at the Ruby Drink-up of Sophia, February 2012](https://reader031.vdocuments.site/reader031/viewer/2022020207/55959eb71a28ab622d8b4627/html5/thumbnails/10.jpg)
Pry as rails console
1. gemfile:gem "pry", :group => :development
2. bundle install3. config/environment/development.rb
silence_warnings do require "pry" IRB = Pryend
4. rails consolepry(main)>
![Page 11: Pry at the Ruby Drink-up of Sophia, February 2012](https://reader031.vdocuments.site/reader031/viewer/2022020207/55959eb71a28ab622d8b4627/html5/thumbnails/11.jpg)
Pry customization
~/.pryrc and ./.pryrc files
Pry.config.inputPry.config.promptPry.config.outputPry.config.printPry.config.exception_handlerPry.config.colorPry.config.pager
![Page 12: Pry at the Ruby Drink-up of Sophia, February 2012](https://reader031.vdocuments.site/reader031/viewer/2022020207/55959eb71a28ab622d8b4627/html5/thumbnails/12.jpg)
Room for improvement
Pry 0.9.8.1
● no completion everywhereno file/path completion on shell commandsshell-mode
● how to retrieve the output of a shell command● object exploration does not support
pwd # use nestingcd -
● cd .. issued from top level context exits # fixed in 0.9.8.1● issue with rspec - binding.pry => NULL pointer given
![Page 13: Pry at the Ruby Drink-up of Sophia, February 2012](https://reader031.vdocuments.site/reader031/viewer/2022020207/55959eb71a28ab622d8b4627/html5/thumbnails/13.jpg)
Thank you.