Eight attendees made it to the February meeting of the New Hampshire Ruby Rails group at the New Hampshire Innovation Commercialization Center. A round of introductions included the usual suspects and several new people with interesting backgrounds and interests.
Brian Turnbull talked about Ruby debugging. He had a sample he created on Github Ruby comes with it’s own debugging library, but you can add a good one with a gem: ruby-debug.
Commands:
list – lists the code currently load
next – steps through the code listed, but skips over subroutines.
step – steps into the code
where – dumps the stack
finish – finishes the current subroutine call
display – dumps a value
(commonly use display value.inspect to make a cleaner display)
pp – pretty print, evaluates any Ruby code you want
edit – launches the EDITOR variable in our shell
catch – catch exceptions
cont – continue
break – set a breakpoint
,,, and so forth. Use the help, it is your friend.
The second example is far more complex, with a Sinatra app using OmniAuth and an LDAP provider. Following the supplied documentation, the app crashes on startup. (That’s what you get for reading the docs!) Debug and another tool – rbtrace to the rescue! Excellent demo of the problem and how the tools can debug them.