Skip to content

rking/pry-full

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pry-full

Get up and going with a good set of pry tools right away.

Dependent Gems

Allows you to look into the Ruby builtin classes with the ? and $ commands.

  • ? [].pop

  • $ [].pop

  • …etc.

Shows docs for dollar-vars and keywords

  • show-docmores

  • ? module

  • ? $`

An essential gem. Turns Pry into a steppable debugger.

  • Making the basic "require'pry';binding.pry" from a script come alive.

  • In conjunction with plymouth or pry-rescue, to explore failing tests.

  • Following calls into other libs.

Allows you to navigate the call stack.

  • So many. TODO = document some.

Provides Pry.rescue do … end to capture any exceptions and start pry from the context of the source of the exception.

  • Shortens write-run-debug cycles when exceptions are involved.

  • Exploring causes of hard-to-replicate exceptions.

  • cd-cause to source of exceptions in code run within Pry

  • Rescues on test failure via require of pry-rescue/minitest and pry-rescue/rspec

An excellent tabcompletion gem. Having this dep enables new Pry stuff. Note that pry v0.9.10 doesn't have this feature, so you must use a repo version.

  • require 'x<tab>

  • {asdf: 1, hjkl: 2}[:a<tab>

  • Chain.of.calls.<tab> # Old pry completion was generic in this case.

Replacement for the undermaintained gist gem.

  • Improved implementation for Pry's gist command.

  • Check out the jist -h output on the CLI, by the way.

Alternative syntax highlighting.

  • Being more snazzy

  • Making pry more like your editor, so you can scan more easily.

A very simple, but nice, plugin. Turns 12345689 into 12_345_689 on output (Which is legal Ruby input).

  • Any time you have big numbers.

Cirwin's wild bag of tricks. The caveat is that it's pretty wild and tricky - especially since input with @s can get rewritten as an instance_variable_get. Still, this is only a matter of understanding the dialect used, and adapting accordingly.

  • Direct member access; User.new.@secret_password

  • Calling private methods; User.new.!hash_password('foo')

  • Accessing Pry outer bindings; cd (a = Object.new) then puts ../a

Reformat strings with pretty-printing. Auto-detects JSON/XML/Ruby.

  • After a method produces ugly XML, do ">>" by itself to see it prettied.

  • Pass in the string as an arg, e.g., >> '{"a":1}'

  • Pass in any Ruby as an arg, >> File.read("/var/www/foo.html")

Pop the current line into a text editor. In tpope's words, "Whenever I'm using IRB or Pry, my editor always feels too far away. Yes, there are [ways to] spawn an editor and evaluate the result, but that's not what I need. Usually I'm about 80 characters or so into a hairy one-liner when I think, "you know, I really wish I was in Vim right about now." In Bash, one can load the current command line into an editor with C-x C-e. And now, you can do so in IRB and Pry."

  • Ctrl+x, Ctrl+e or Ctrl+o (if in Emacs mode or Vi Insert Mode)

  • v or o (if in Vi Normal Mode)

Method-level git commands.

  • Blame/diff a specific method.

Mostly for Pry/Pry Plugin development, but can be useful interactively.

  • define-command 'r', 'rerun' do run 'history --replay -1' end

  • reload-command show-method

  • edit-command show-method

  • edit-command -p show-method

Not a Pry plugin, but a useful tool, still.

  • Gnarly objects. ap the_gnarly_obj

About

Get up and going with a good set of pry tools right away.

Resources

License

Stars

Watchers

Forks

Packages

No packages published