Class: Gem::Resolver::IndexSpecification

Inherits:
Specification show all
Defined in:
lib/rubygems/resolver/index_specification.rb

Overview

Represents a possible Specification object returned from IndexSet. Used to delay needed to download full Specification objects when only the name and version are needed.

Instance Attribute Summary

Attributes inherited from Specification

#name, #platform, #set, #source, #version

Instance Method Summary collapse

Methods inherited from Specification

#download, #fetch_development_dependencies, #full_name, #install, #installable_platform?, #local?

Constructor Details

#initialize(set, name, version, source, platform) ⇒ IndexSpecification

An IndexSpecification is created from the index format described in ‘gem help generate_index`.

The set contains other specifications for this (URL) source.

The name, version and platform are the name, version and platform of the gem.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rubygems/resolver/index_specification.rb', line 18

def initialize(set, name, version, source, platform)
  super()

  @set = set
  @name = name
  @version = version
  @source = source
  @platform = platform.to_s

  @spec = nil
end

Instance Method Details

#dependenciesObject

The dependencies of the gem for this specification



33
34
35
# File 'lib/rubygems/resolver/index_specification.rb', line 33

def dependencies
  spec.dependencies
end

#inspectObject

:nodoc:



37
38
39
# File 'lib/rubygems/resolver/index_specification.rb', line 37

def inspect # :nodoc:
  '#<%s %s source %s>' % [self.class, full_name, @source]
end

#pretty_print(q) ⇒ Object

:nodoc:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rubygems/resolver/index_specification.rb', line 41

def pretty_print(q) # :nodoc:
  q.group 2, '[Index specification', ']' do
    q.breakable
    q.text full_name

    unless Gem::Platform::RUBY == @platform
      q.breakable
      q.text @platform.to_s
    end

    q.breakable
    q.text 'source '
    q.pp @source
  end
end

#specObject

Fetches a Gem::Specification for this IndexSpecification from the #source.



60
61
62
63
64
65
66
67
# File 'lib/rubygems/resolver/index_specification.rb', line 60

def spec # :nodoc:
  @spec ||=
    begin
      tuple = Gem::NameTuple.new @name, @version, @platform

      @source.fetch_spec tuple
    end
end