I love me some source
01
Feb
I don’t know if its because I’m nosy, or because I’m a control freak, or perhaps both, but I really do like to read the source code. It occurs to me that this is probably why I feel so at home in the open source world.
As much as I like something like Cocoa, it pains me not to be able to trace problems all the way down the stack. Even java solved this problem by shipping with its own source.
Proclivities aside, I really like source, and am always looking for ways to make it easier to get at. cd /usr/lib/ruby/gems/1.8/gems gets old quick.
I started with this little cough gem from Dr Nic. Integrating it with my shell, I could now type
1 | $ gems activerecord |
and up pops the activerecord gem in Textmate. So some new releases of activerecord came out, and suddenly my naive script is giving me the old version. Without looking too far into it I added gem requirement support so that I could type
1 | $ gems activerecord '>=2' |
and get a recent activerecord in Textmate. As good as this is, I was really after something with less typing and smarter pants. Well tonight I cracked it and I thought I’d open the source:
1 2 3 4 5 6 7 8 9 10 11 | #!/usr/bin/env ruby
require ENV['TM_SUPPORT_PATH']+"/lib/ui"
require 'rubygems'
gems = Gem.source_index.latest_specs.collect {|spec| spec.full_name}.sort
TextMate::UI.request_item(:title => 'open a gem', :items => gems) do |selected_gem|
gem_path = Gem.source_index.specification(selected_gem).full_gem_path
%x{open -a TextMate #{gem_path}}
end |
Honestly, that’s it! Bung that in a command using Textmate’s Bundle Editor and assign it a key (I gave it cmd-shift-G, as I don’t regularly search backwards).

Double click on one and you’re golden… neat.

February 01, 2008 at 2:15 PM
Nice UI.
I later integrated that pastie into a gem find_gem.
Has two command-line apps: find_gem name, and edit_gem name; the later opening up the gem into TextMate etc.
Also has some nice autocompletions for bash if you look in the readme, I think.
February 11, 2008 at 2:50 AM
Wicked! I will be using this alot!
April 11, 2008 at 1:31 PM
Nice work!
April 11, 2008 at 1:31 PM
Nice work!
April 14, 2008 at 4:24 PM
Cool. While tiny, why not make it into a gem as well? Or perhaps hand it off to Giles Bowkett and make it part of the utility_belt gem. Seems appropriate for it.
April 14, 2008 at 4:25 PM
Ok, forget what I said about utility_belt integration; it's focused on IRB enhancements. This is a command line enhancement.
April 16, 2008 at 2:03 PM
Great post. This is really helpful!
May 14, 2008 at 4:30 PM
You might want to check out my little gem called gemedit, which allows gems to be opened in any editor and has command line completion.
http://gemedit.rubyforge.org/
August 06, 2008 at 4:06 AM
Sweeeeeeeeeeeeeeeeet