Class: Gem::Resolver::LockSpecification
- Inherits:
-
Specification
- Object
- Specification
- Gem::Resolver::LockSpecification
- 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 collapse
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Attributes inherited from Specification
#dependencies, #name, #platform, #set, #source, #version
Instance Method Summary collapse
-
#add_dependency(dependency) ⇒ Object
Adds
dependency
from the lockfile to this specification. -
#initialize(set, name, version, sources, platform) ⇒ LockSpecification
constructor
A new instance of LockSpecification.
-
#install(options = {}) ⇒ Object
This is a null install as a locked specification is considered installed.
-
#pretty_print(q) ⇒ Object
:nodoc:.
-
#spec ⇒ Object
A specification constructed from the lockfile is returned.
Methods inherited from Specification
#download, #fetch_development_dependencies, #full_name, #installable_platform?, #local?
Constructor Details
#initialize(set, name, version, sources, platform) ⇒ LockSpecification
Returns a new instance of LockSpecification.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rubygems/resolver/lock_specification.rb', line 12 def initialize(set, name, version, sources, platform) super() @name = name @platform = platform @set = set @source = sources.first @sources = sources @version = version @dependencies = [] @spec = nil end |
Instance Attribute Details
#sources ⇒ Object (readonly)
Returns the value of attribute sources
10 11 12 |
# File 'lib/rubygems/resolver/lock_specification.rb', line 10 def sources @sources end |
Instance Method Details
#add_dependency(dependency) ⇒ Object
Adds dependency
from the lockfile to this specification
44 45 46 |
# File 'lib/rubygems/resolver/lock_specification.rb', line 44 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.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubygems/resolver/lock_specification.rb', line 30 def install( = {}) destination = [:install_dir] || Gem.dir if File.exist? File.join(destination, 'specifications', spec.spec_name) yield nil return end super end |
#pretty_print(q) ⇒ Object
:nodoc:
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rubygems/resolver/lock_specification.rb', line 48 def pretty_print(q) # :nodoc: q.group 2, '[LockSpecification', ']' do q.breakable q.text "name: #{@name}" q.breakable q.text "version: #{@version}" unless @platform == Gem::Platform::RUBY q.breakable q.text "platform: #{@platform}" end unless @dependencies.empty? q.breakable q.text 'dependencies:' q.breakable q.pp @dependencies end end end |
#spec ⇒ Object
A specification constructed from the lockfile is returned
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/rubygems/resolver/lock_specification.rb', line 73 def spec @spec ||= Gem::Specification.find do |spec| spec.name == @name and spec.version == @version end @spec ||= Gem::Specification.new do |s| s.name = @name s.version = @version s.platform = @platform s.dependencies.concat @dependencies end end |