Top Level Namespace

Defined Under Namespace

Modules: HeapDump

Instance Method Summary collapse

Instance Method Details

#find_gem_dir(name, *req) ⇒ Object



16
17
18
19
20
# File 'ext/heap_dump/extconf.rb', line 16

def find_gem_dir(name, *req)
  gem = find_spec(name, *req)
  return gem.gem_dir if gem.respond_to? :gem_dir
  gem.full_gem_path
end

#find_spec(name, *requirements) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'ext/heap_dump/extconf.rb', line 3

def find_spec name,*requirements
  return Gem::Specification.find_by_name(name, *requirements) if Gem::Specification.respond_to? :find_by_name

  requirements = Gem::Requirement.default if requirements.empty?

  gem = Gem::Dependency.new(name, *requirements)
  matches = Gem.source_index.find_name(gem.name, gem.requirement)
  raise "No matching #{name} gem!" unless matches.any?
  matches.find { |spec|
    Gem.loaded_specs[gem.name] == spec
    } or matches.last
end