List Info

Thread: methdos for active?, gemspec and location




methdos for active?, gemspec and location
user name
2007-04-16 12:21:38
Does RubyGems have means for determining if a gem is active
or not?
And a way to get it's gemspec and locating it's files? I had
written
these extensions for doing so sometime ago. Hopefully there
are
built-in ways for accessing such information and these
aren't of use
anymore. Otherwise perhaps they could be used to provide
that access.

 module Gem

  # Is a gem active?
  def self.active?(gemname)
    loaded_specs ||= Hash.new
    loaded_specs.key? gemname
  end

  # path to active gem's files
  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

  # an active gems gemspec
  def self.gemspec(gemname)
    loaded_specs[gemname] if active?(gemname)
  end

 end
_______________________________________________
Rubygems-developers mailing list
Rubygems-developersrubyforge.org
http://rubyforge.org/mailman/listinfo/rubygems-develope
rs

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )