Debugger Snippets

5 views
Skip to first unread message

William Taysom

unread,
Mar 26, 2012, 8:50:29 AM3/26/12
to gzr...@googlegroups.com
Hi Guys,

I'm remembered those Ruby snippets for you. In TextMate, trigger these using the "source.ruby" scope selector. In other other editors you're on your own.

Set a ruby-debug breakpoint:

(require 'ruby-debug'; debugger; nil) #!!

Set a pry breakpoint:

(require 'pry'; binding.pry) #!!

Print an expression:

puts "${1:var}: #{(${1}).inspect}" #!!

Pretty print an expression (assumes you've required 'pp'):

puts "== ${1:var} ==" #!!
pp(${1})
puts

Print the class and method name of the current method:

puts "#{self.class}##{__method__}" #!!

I use "#!!" to mark temporary lines of code. As Adeh said, a svn commit hook to prevent accidental committing of the pattern would be a boon.

Happy Rubying,
William

Senori Liu

unread,
Mar 27, 2012, 11:59:19 PM3/27/12
to gzr...@googlegroups.com
Thanks for sharing... though I am a vim user...
Reply all
Reply to author
Forward
0 new messages