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.



41
42
43
44
45
46
47
48
# File 'lib/rubygems/resolver/specification.rb', line 41

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

#versionObject (readonly)

The version of the gem for this specification.



36
37
38
# File 'lib/rubygems/resolver/specification.rb', line 36

def version
  @version
end

Instance Method Details

#full_nameObject

The name and version of the specification.

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



55
56
57
# File 'lib/rubygems/resolver/specification.rb', line 55

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.

Yields:

  • (installer)


65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/rubygems/resolver/specification.rb', line 65

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?

  installer.install
end

#installable_platform?Boolean

Returns true if this specification is installable on this platform.

Returns:

  • (Boolean)


84
85
86
# File 'lib/rubygems/resolver/specification.rb', line 84

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