Class: Gem::Resolver::LockSpecification

Inherits:
Specification show all
Defined in:
lib/rubygems/resolver/lock_specification.rb

Overview

The LockSpecification comes from a lockfile (Gem::RequestSet::Lockfile).

A LockSpecification’s dependency information is pre-filled from the lockfile.

Instance Attribute Summary

Attributes inherited from Specification

#dependencies, #name, #platform, #set, #source, #version

Instance Method Summary collapse

Methods inherited from Specification

#full_name, #installable_platform?

Constructor Details

#initialize(set, name, version, source, platform) ⇒ LockSpecification

Returns a new instance of LockSpecification.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rubygems/resolver/lock_specification.rb', line 9

def initialize set, name, version, source, platform
  super()

  @name     = name
  @platform = platform
  @set      = set
  @source   = source
  @version  = version

  @dependencies = []
  @spec         = nil
end

Instance Method Details

#add_dependency(dependency) ⇒ Object

Adds dependency from the lockfile to this specification



40
41
42
# File 'lib/rubygems/resolver/lock_specification.rb', line 40

def add_dependency dependency # :nodoc:
  @dependencies << dependency
end

#install(options) ⇒ Object

This is a null install as a locked specification is considered installed. options are ignored.



26
27
28
29
30
31
32
33
34
35
# File 'lib/rubygems/resolver/lock_specification.rb', line 26

def install options
  destination = options[:install_dir] || Gem.dir

  if File.exist? File.join(destination, 'specifications', spec.spec_name) then
    yield nil
    return
  end

  super
end

#specObject

A specification constructed from the lockfile is returned



47
48
49
50
51
52
53
54
55
# File 'lib/rubygems/resolver/lock_specification.rb', line 47

def spec
  @spec ||= Gem::Specification.new do |s|
    s.name     = @name
    s.version  = @version
    s.platform = @platform

    s.dependencies.concat @dependencies
  end
end