Skip to content

Instantly share code, notes, and snippets.

@localhost
Created June 10, 2009 14:29
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 localhost/127240 to your computer and use it in GitHub Desktop.
Save localhost/127240 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# find_gem - improved by freQvibez
#
# originally hacked by Dr Nic:
# http://drnic.tumblr.com/post/166472/load-up-any-gem-into-editor
#
# example: mate `find_gem mongrel mongrel_cluster`
require 'rubygems'
begin
if ARGV.first
puts Gem.source_index.find_name(ARGV.shift).last.full_gem_path while gem = ARGV.first
else
puts Gem.source_index.find_name('sources').last.full_gem_path.split('sources').first
end
rescue err = NoMethodError
$stderr.puts "#{$0} #{gem}: No such gem"
retry if ARGV.first
end
exit err.nil?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment