2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2013-07-09 19:21:36 -04:00
|
|
|
##
|
2013-09-24 20:53:19 -04:00
|
|
|
# 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.
|
2013-07-09 19:21:36 -04:00
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
class Gem::Resolver::IndexSpecification < Gem::Resolver::Specification
|
2013-11-10 12:51:40 -05:00
|
|
|
##
|
|
|
|
# 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.
|
2013-07-09 19:21:36 -04:00
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def initialize(set, name, version, source, platform)
|
2013-11-10 12:51:40 -05:00
|
|
|
super()
|
|
|
|
|
2013-07-09 19:21:36 -04:00
|
|
|
@set = set
|
|
|
|
@name = name
|
|
|
|
@version = version
|
|
|
|
@source = source
|
2013-10-15 20:14:16 -04:00
|
|
|
@platform = platform.to_s
|
2013-07-09 19:21:36 -04:00
|
|
|
|
|
|
|
@spec = nil
|
|
|
|
end
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
##
|
|
|
|
# The dependencies of the gem for this specification
|
|
|
|
|
2013-07-09 19:21:36 -04:00
|
|
|
def dependencies
|
|
|
|
spec.dependencies
|
|
|
|
end
|
|
|
|
|
2020-12-08 02:33:39 -05:00
|
|
|
def ==(other)
|
|
|
|
self.class === other &&
|
|
|
|
@name == other.name &&
|
|
|
|
@version == other.version &&
|
|
|
|
@platform == other.platform
|
|
|
|
end
|
|
|
|
|
|
|
|
def hash
|
|
|
|
@name.hash ^ @version.hash ^ @platform.hash
|
|
|
|
end
|
|
|
|
|
2013-07-09 19:21:36 -04:00
|
|
|
def inspect # :nodoc:
|
|
|
|
'#<%s %s source %s>' % [self.class, full_name, @source]
|
|
|
|
end
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def pretty_print(q) # :nodoc:
|
2013-07-09 19:21:36 -04:00
|
|
|
q.group 2, '[Index specification', ']' do
|
|
|
|
q.breakable
|
|
|
|
q.text full_name
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
unless Gem::Platform::RUBY == @platform
|
2013-09-09 20:52:14 -04:00
|
|
|
q.breakable
|
2013-09-12 21:40:42 -04:00
|
|
|
q.text @platform.to_s
|
2013-09-09 20:52:14 -04:00
|
|
|
end
|
|
|
|
|
2013-07-09 19:21:36 -04:00
|
|
|
q.breakable
|
2013-09-09 20:52:14 -04:00
|
|
|
q.text 'source '
|
2013-07-09 19:21:36 -04:00
|
|
|
q.pp @source
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
##
|
|
|
|
# Fetches a Gem::Specification for this IndexSpecification from the #source.
|
|
|
|
|
|
|
|
def spec # :nodoc:
|
|
|
|
@spec ||=
|
|
|
|
begin
|
|
|
|
tuple = Gem::NameTuple.new @name, @version, @platform
|
|
|
|
|
|
|
|
@source.fetch_spec tuple
|
|
|
|
end
|
2013-07-09 19:21:36 -04:00
|
|
|
end
|
|
|
|
end
|