123456789_123456789_123456789_123456789_123456789_

Class: Gem::Resolver::Specification

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object
Defined in: lib/rubygems/resolver/specification.rb

Overview

A Specification contains a subset of the information contained in a ::Gem::Specification. Only the information necessary for dependency resolution in the resolver is included.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.newSpecification

Sets default instance variables for the specification.

[ GitHub ]

  
# File 'lib/rubygems/resolver/specification.rb', line 49

def initialize
  @dependencies = nil
  @name         = nil
  @platform     = nil
  @set          = nil
  @source       = nil
  @version      = nil
end

Instance Attribute Details

#dependencies (readonly)

The dependencies of the gem for this specification

[ GitHub ]

  
# File 'lib/rubygems/resolver/specification.rb', line 11

attr_reader :dependencies

#installable_platform?Boolean (readonly)

Returns true if this specification is installable on this platform.

[ GitHub ]

  
# File 'lib/rubygems/resolver/specification.rb', line 102

def installable_platform?
  Gem::Platform.match spec.platform
end

#name (readonly)

The name of the gem for this specification

[ GitHub ]

  
# File 'lib/rubygems/resolver/specification.rb', line 16

attr_reader :name

#platform (readonly)

The platform this gem works on.

[ GitHub ]

  
# File 'lib/rubygems/resolver/specification.rb', line 21

attr_reader :platform

#set (readonly)

The set this specification came from.

[ GitHub ]

  
# File 'lib/rubygems/resolver/specification.rb', line 26

attr_reader :set

#source (readonly)

The source for this specification

[ GitHub ]

  
# File 'lib/rubygems/resolver/specification.rb', line 31

attr_reader :source

#spec (readonly)

The ::Gem::Specification for this Specification.

Implementers, note that #install updates @spec, so be sure to cache the ::Gem::Specification in @spec when overriding.

[ GitHub ]

  
# File 'lib/rubygems/resolver/specification.rb', line 39

attr_reader :spec

#version (readonly)

The version of the gem for this specification.

[ GitHub ]

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

attr_reader :version

Instance Method Details

#full_name

The name and version of the specification.

Unlike Specification#full_name, the platform is not included.

[ GitHub ]

  
# File 'lib/rubygems/resolver/specification.rb', line 70

def full_name
  "#{@name}-#{@version}"
end

#install(options = {}) {|installer| ... }

Installs this specification using the ::Gem::Installer options. The install method yields a ::Gem::Installer instance, which indicates the gem will be installed, or nil, which indicates the gem is already installed.

After installation #spec is updated to point to the just-installed specification.

Yields:

[ GitHub ]

  
# File 'lib/rubygems/resolver/specification.rb', line 83

def install options = {}
  require 'rubygems/installer'

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

  Gem.ensure_gem_subdirectories destination

  gem = source.download spec, destination

  installer = Gem::Installer.new gem, options

  yield installer if block_given?

  @spec = installer.install
end