[Rubygems-developers] Gem.active?, Gem.gemspec and Gem.gempath

Trans transfire at gmail.com
Wed Jun 24 07:36:12 EDT 2009


Hi--

I have these extensions I've used on a couple of occasions. I just
tested them out again and they still seem to be working fine. Maybe
other's are interested. Or perhaps there are other better ways to do
these things?

  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

Thanks,
Trans.


More information about the Rubygems-developers mailing list