views:

47

answers:

2

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.

A: 

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!

mistertim
Yes, this is what I'm doing now. Thought there were maybe some different tools I wasn't aware of.
Dex
aah, i'm sorry - i missed that bit of your post. bundler ('gem install bundler') will make it easier to manage the gem dependencies in your own projects, so if you want to rely on your patched version of a gem, rather than the canonical version, you can specify this and have bundler keep track of the dependency for you.
mistertim
In terms of contributing back to projects, the standard workflow (assuming the project is hosted on github) seems to be - fork the git repository for the project ,make your changes on your fork (including tests for any changes), then submit a pull request to the source project. The maintainer can then pull the changes from your fork and include them in a release. Hope this helps!
mistertim
It seems that you can't edit the libraries without having to restart the Rails server. Oh well. Bundler does make it easier I've found, just change the version string to :path => "/some/dir"
Dex