summaryrefslogtreecommitdiff
path: root/lib/rubygems/dependency_resolver/index_specification.rb
blob: 6cf267dac122fa2e8a237e1a32582c9a8262e5c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
##
# 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.

class Gem::DependencyResolver::IndexSpecification

  attr_reader :name

  attr_reader :platform

  attr_reader :source

  attr_reader :version

  def initialize set, name, version, source, platform
    @set = set
    @name = name
    @version = version
    @source = source
    @platform = platform.to_s

    @spec = nil
  end

  def dependencies
    spec.dependencies
  end

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

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

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

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

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

  def spec
    @spec ||= @set.load_spec(@name, @version, @platform, @source)
  end

end