Opening Gems in Textmate

Here’s a problem: you need to look at a gem’s source code to figure out something, but you need to figure out the path to your gems directory, find the gem in question, and then open it from there. What a pain. Luckily, Dr. Nic has saved the day:

$ sudo gem install find_gem
$ find_gem activerecord

This also comes with the wonderful command ‘edit_gem’. Make sure you have your environment EDITOR variable set in your .bash_login|.bash_profile|.bashrc:

export EDITOR="mate"

Save the file and source it:

$ source .bash_profile # or .bashrc

Now, “edit_gem activerecord” does what you think it should do. Nice little pieces of functionality like these really make the term “gem” so appropriate. Hat-tip to Graham Ashton for sparking my interest to find a solution.

blog comments powered by Disqus