Class: Gem::Specification

Inherits:
Object show all
Defined in:
lib/standard/facets/gem/specification/current_specs.rb,
lib/standard/facets/gem/specification/find_requireable_file.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.


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/standard/facets/gem/specification/current_specs.rb', line 5

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_requireable_file(file) ⇒ Object

Return full path of requireable file given relative path.


5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/standard/facets/gem/specification/find_requireable_file.rb', line 5

def find_requireable_file(file)
  root = full_gem_path

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

  return nil
end