Class: Gem::Resolver::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygems/resolver/specification.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSpecification

Sets default instance variables for the specification.


49
50
51
52
53
54
55
56
# 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

#dependenciesObject (readonly)

The dependencies of the gem for this specification


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

def dependencies
  @dependencies
end

#nameObject (readonly)

The name of the gem for this specification


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

def name
  @name
end

#platformObject (readonly)

The platform this gem works on.


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

def platform
  @platform
end

#setObject (readonly)

The set this specification came from.


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

def set
  @set
end

#sourceObject (readonly)

The source for this specification


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

def source
  @source
end

#specObject (readonly)

The Gem::Specification for this Resolver::Specification.

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


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

def spec
  @spec
end

#versionObject (readonly)

The version of the gem for this specification.


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

def version
  @version
end

Instance Method Details

#download(options) ⇒ Object


95
96
97
98
99
100
101
# File 'lib/rubygems/resolver/specification.rb', line 95

def download(options)
  dir = options[:install_dir] || Gem.dir

  Gem.ensure_gem_subdirectories dir

  source.download spec, dir
end

#fetch_development_dependenciesObject

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


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

def fetch_development_dependencies # :nodoc:
end

#full_nameObject

The name and version of the specification.

Unlike Gem::Specification#full_name, the platform is not included.


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

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

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

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:

  • (installer)

83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rubygems/resolver/specification.rb', line 83

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

  gem = download options

  installer = Gem::Installer.at gem, options

  yield installer if block_given?

  @spec = installer.install
end

#installable_platform?Boolean

Returns true if this specification is installable on this platform.

Returns:

  • (Boolean)

106
107
108
# File 'lib/rubygems/resolver/specification.rb', line 106

def installable_platform?
  Gem::Platform.match_spec? spec
end

#local?Boolean

:nodoc:

Returns:

  • (Boolean)

110
111
112
# File 'lib/rubygems/resolver/specification.rb', line 110

def local? # :nodoc:
  false
end