Skip to content

Instantly share code, notes, and snippets.

@jamesmacaulay
Created September 16, 2008 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesmacaulay/11052 to your computer and use it in GitHub Desktop.
Save jamesmacaulay/11052 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# gemmate
# open the directory of a rubygem as a project in textmate
# responds to anything that `gem which` can handle
# e.g.:
# gemmate autotest
# => `mate /Library/Ruby/Gems/1.8/gems/ZenTest-3.11.0`
# gemmate active_record
# => `mate /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2`
file = `gem which --no-verbose #{ARGV[0]}`
chunks = File.dirname(file).split(File::SEPARATOR)
chunks.reverse.each_with_index do |chunk, i|
break if chunks[-2] == 'gems'
chunks.pop
end
puts (cmd = "mate #{File.join chunks}")
system(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment