Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Pry at the Ruby Drink-up of Sophia, February 2012

1,840 views

Published on

Presented at the Ruby Drink-up of Sophia Antipolis on the 7th of February 2012 by Philippe Antras (@_philant_).

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Pry at the Ruby Drink-up of Sophia, February 2012

  1. 1. A quick overview Philippe Antras @_philant_
  2. 2. PryREPLCan 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
  3. 3. > gem install pry
  4. 4. Some Pry commandsTo get a list of all commands:Pry(main)> helpshow-doc space to escape command:show-method pry(main)> cat = "fido"history <your commands here>play -f <file>edit <file>edit [input buffer]ri Array#each
  5. 5. Pry interactions ●; ●! ● edit ● <space> ● _ <underscore> ● history ● history --replay 101..105
  6. 6. shell commandsPry assumes commands prefixed with a dot are shell commandspry(main)> .ls -lpry(main)> .svn updatepry(main)> .cat #{temp_file}pry(main)> shell-mode #limited completion
  7. 7. 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 = historypry(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)
  8. 8. debugging with Pryruntime invocationbinding.pry<object>.prywhereami
  9. 9. Documentation and source browsinginstall the pry-doc plugin:> gem install pry-docpry(main)> a = [1, 2, 3]pry(main)> ls a -mpry(main)> show-doc a.nitemspry(main)> ls Array -Mpry(main)> show-doc Array#shelljoinpry(main)> show-method Array#shelljoin
  10. 10. Pry as rails console1. gemfile: gem "pry", :group => :development2. bundle install3. config/environment/development.rb silence_warnings do require "pry" IRB = Pry end4. rails console pry(main)>
  11. 11. Pry customization~/.pryrc and ./.pryrc filesPry.config.inputPry.config.promptPry.config.outputPry.config.printPry.config.exception_handlerPry.config.colorPry.config.pager
  12. 12. Room for improvementPry 0.9.8.1 ● no completion everywhere no file/path completion on shell commands shell-mode ● how to retrieve the output of a shell command ● object exploration does not support pwd # use nesting cd - ● cd .. issued from top level context exits # fixed in 0.9.8.1 ● issue with rspec - binding.pry => NULL pointer given
  13. 13. Thank you.

×