Module: Gem

Defined in:
lib/rubygems-find/find.rb

Class Method Summary collapse

Class Method Details

.find(dir) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rubygems-find/find.rb', line 4

def self.find(dir)
  dir = File.expand_path(dir)
  gemspecs = {}
  spec_files = Dir.glob(File.join(dir, "**/*.gemspec"))
  spec_files.each do |spec_file|
    Dir.chdir(File.expand_path(File.dirname(spec_file), dir))
    spec = Gem::Specification.load(spec_file)
    if spec
      spec.normalize
      o = {}
      spec.class.attribute_names.find_all do |name|
        v = spec.instance_variable_get("@#{name}")
        o[name] = v if v
      end
      gemspecs[spec_file] = o
    end
  end
  gemspecs
end