Ruby Debugging Open Source Libraries
I would like to debug and possibly contribute to some open source gems but am fairly new to Ruby and开发者_高级运维 Rails. What is the best way to go in and start setting breakpoints, etc?
Right now I just use ruby-debug for my own code and inspect variables mostly.
you need the ruby-debugger gem. Make sure you have have rubygems installed, then do
gem install ruby-debug
Then, add the line
require 'ruby-debug'
to your sourcecode to load the library, and add the keyword 'debugger' wherever you want to set a breakpoint. Now, whenever you call the code in question, it'll drop to the debugging console when it reaches the breakpoint - press h to see a list of options to see what you can do from there. Obviously, remember to remove your breakpoints and the require statement after you're done!
精彩评论