Ruby on Rails: How to open the source for a ruby gem easily using bundler
May 1, 2012 | by Paul Leader
No matter how good the documentation for a Ruby gem might be, from time to time you’ll probably need to dig around in the code to check or confirm exactly what it does, or what options it might take.
In most cases the source for a Gem will be in GitHub, for easy browsing. However there is no good way to search this.
A better and easier approach is to simply open the gem’s source on your own machine using your favorite editor. You can do this with bundler, e.g….
bundle open paperclip
would open the Paperclip gem’s source tree in your editor, based on what you have set your EDITOR environment variable to, in my case that’s Textmate.
This also makes it easy for you to tweak a gem temporarily, for example if you need to instrument it to get better debug information.
This is one of those commands I wish I’d known about years ago for all the time it is now saving me.