Class: Gem::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/gel/compatibility/rubygems.rb,
lib/gel/catalog/marshal_hacks.rb

Defined Under Namespace

Classes: Unmarshalled

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store_gem) ⇒ Specification

Returns a new instance of Specification.



43
44
45
# File 'lib/gel/compatibility/rubygems.rb', line 43

def initialize(store_gem)
  @store_gem = store_gem
end

Class Method Details

._load(str) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/gel/catalog/marshal_hacks.rb', line 9

def self._load(str)
  array = Marshal.load(str)
  o = Unmarshalled.new
  o.required_ruby_version = array[6].as_list
  o.dependencies = array[9].map { |d| [d.name, d.requirement.as_list] if d.type == :runtime }.compact
  o
end

.each(&block) ⇒ Object



39
40
41
# File 'lib/gel/compatibility/rubygems.rb', line 39

def self.each(&block)
  Gel::Environment.store.each.map { |g| new(g) }.each(&block)
end

.find_by_name(name, *requirements) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/gel/compatibility/rubygems.rb', line 30

def self.find_by_name(name, *requirements)
  if g = Gel::Environment.find_gem(name, *requirements)
    new(g)
  else
    # TODO: Should probably be a Gel exception instead?
    raise Gem::LoadError, "Unable to find gem #{name.inspect}" + (requirements.empty? ? "" : " (#{requirements.join(", ")})")
  end
end

Instance Method Details

#dependenciesObject Also known as: runtime_dependencies



55
56
57
58
59
# File 'lib/gel/compatibility/rubygems.rb', line 55

def dependencies
  @store_gem.dependencies.map do |name, pairs|
    Gem::Dependency.new(name, pairs.map { |op, ver| "#{op} #{ver}" }, :runtime)
  end
end

#gem_dirObject Also known as: full_gem_path



62
63
64
# File 'lib/gel/compatibility/rubygems.rb', line 62

def gem_dir
  @store_gem.root
end

#nameObject



47
48
49
# File 'lib/gel/compatibility/rubygems.rb', line 47

def name
  @store_gem.name
end

#require_pathsObject



67
68
69
70
71
72
73
# File 'lib/gel/compatibility/rubygems.rb', line 67

def require_paths
  base = Pathname.new(gem_dir)

  @store_gem.require_paths.map do |path|
    Pathname.new(path).relative_path_from(base).to_s
  end
end

#versionObject



51
52
53
# File 'lib/gel/compatibility/rubygems.rb', line 51

def version
  Gem::Version.new(@store_gem.version)
end