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
$ 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
$ 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:
#!/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 2nd, 2008 at 01:15 AM 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 11th, 2008 at 01:50 PM Wicked! I will be using this alot!
April 11th, 2008 at 11:31 PM Nice work!
April 11th, 2008 at 11:31 PM Nice work!
April 15th, 2008 at 02:24 AM 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 15th, 2008 at 02:25 AM Ok, forget what I said about utility_belt integration; it's focused on IRB enhancements. This is a command line enhancement.
April 17th, 2008 at 12:03 AM Great post. This is really helpful!
May 15th, 2008 at 02:30 AM 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/
July 1st, 2008 at 12:28 AM Nice Site! http://google.com