123456789_123456789_123456789_123456789_123456789_

Class: Gem::Resolver::LockSpecification

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: Gem::Resolver::Specification
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.

Class Method Summary

Specification - Inherited

.new

Sets default instance variables for the specification.

Instance Attribute Summary

Specification - Inherited

#dependencies

The dependencies of the gem for this specification.

#installable_platform?

Returns true if this specification is installable on this platform.

#name

The name of the gem for this specification.

#platform

The platform this gem works on.

#required_ruby_version

The required_ruby_version constraint for this specification.

#required_rubygems_version

The required_ruby_version constraint for this specification.

#set

The set this specification came from.

#source

The source for this specification.

#spec
#version

The version of the gem for this specification.

#local?

Instance Method Summary

Specification - Inherited

#download,
#full_name

The name and version of the specification.

#install

Installs this specification using the ::Gem::Installer options.

#fetch_development_dependencies

Fetches development dependencies if the source does not provide them by default (see APISpecification).

Constructor Details

.new(set, name, version, sources, platform) ⇒ LockSpecification

[ GitHub ]

  
# 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 (readonly)

[ GitHub ]

  
# File 'lib/rubygems/resolver/lock_specification.rb', line 10

attr_reader :sources

Instance Method Details

#add_dependency(dependency)

This method is for internal use only.

Adds dependency from the lockfile to this specification

[ GitHub ]

  
# File 'lib/rubygems/resolver/lock_specification.rb', line 44

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

#install(options = {})

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

[ GitHub ]

  
# File 'lib/rubygems/resolver/lock_specification.rb', line 30

def install(options = {})
  destination = options[:install_dir] || Gem.dir

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

  super
end

#pretty_print(q)

This method is for internal use only.
[ GitHub ]

  
# 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

A specification constructed from the lockfile is returned

[ GitHub ]

  
# File 'lib/rubygems/resolver/lock_specification.rb', line 73

def spec
  @spec ||= Gem::Specification.find do |spec|
    spec.name == @name && 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