Class: Gem::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/loadable/core_ext/rubygems.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.current_specsObject

Return a list of active specs or latest version of spec if not active.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/loadable/core_ext/rubygems.rb', line 18

def self.current_specs
  named = Hash.new{|h,k| h[k] = [] }
  each{ |spec| named[spec.name] << spec }
  list = []
  named.each do |name, vers|
    if spec = vers.find{ |s| s.activated? }
      list << spec
    else
      spec = vers.max{ |a,b| a.version <=> b.version }
      list << spec
    end
  end
  return list
end

Instance Method Details

#find_requirable_file(file) ⇒ Object

Return full path of requireable file path given relative path.



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/loadable/core_ext/rubygems.rb', line 34

def find_requirable_file(file)
  root = full_gem_path

  require_paths.each do |lib|
    base = "#{root}/#{lib}/#{file}"
    Gem.suffixes.each do |suf|
      path = "#{base}#{suf}"
      return path if File.file? path
    end
  end

  return nil
end