Skip to content

Instantly share code, notes, and snippets.

@trans
Created June 24, 2009 11:24
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 trans/135187 to your computer and use it in GitHub Desktop.
Save trans/135187 to your computer and use it in GitHub Desktop.
Gem.active?
# Gem.active?, Gem.gemspec and Gem.gempath.
# These are RubyGems extensions I created a while back.
# I'm not sure how relevant they are any longer however.
# Does RubyGems now have other means to do these?
module Gem
def self.active?(gemname)
@loaded_specs ||= Hash.new
@loaded_specs.key? gemname
end
def self.gemspec(gemname)
@loaded_specs[gemname] if active?(gemname)
end
def self.gempath(gemname, subdir=nil)
if active?(gemname)
if subdir
File.join( @loaded_specs[gemname].full_gem_path, subdir )
else
@loaded_specs[gemname].full_gem_path
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment