2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2013-07-09 19:21:36 -04:00
|
|
|
##
|
|
|
|
# The global rubygems pool represented via the traditional
|
|
|
|
# source index.
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
class Gem::Resolver::IndexSet < Gem::Resolver::Set
|
2018-11-21 05:20:47 -05:00
|
|
|
def initialize(source = nil) # :nodoc:
|
2014-02-03 19:48:31 -05:00
|
|
|
super()
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
@f =
|
2018-11-21 05:20:47 -05:00
|
|
|
if source
|
2013-11-10 12:51:40 -05:00
|
|
|
sources = Gem::SourceList.from [source]
|
|
|
|
|
|
|
|
Gem::SpecFetcher.new sources
|
|
|
|
else
|
|
|
|
Gem::SpecFetcher.fetcher
|
|
|
|
end
|
2013-07-09 19:21:36 -04:00
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
@all = Hash.new {|h,k| h[k] = [] }
|
2013-07-09 19:21:36 -04:00
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
list, errors = @f.available_specs :complete
|
|
|
|
|
|
|
|
@errors.concat errors
|
2013-07-09 19:21:36 -04:00
|
|
|
|
|
|
|
list.each do |uri, specs|
|
|
|
|
specs.each do |n|
|
|
|
|
@all[n.name] << [uri, n]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@specs = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Return an array of IndexSpecification objects matching
|
|
|
|
# DependencyRequest +req+.
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def find_all(req)
|
2013-07-09 19:21:36 -04:00
|
|
|
res = []
|
|
|
|
|
2014-02-03 19:48:31 -05:00
|
|
|
return res unless @remote
|
|
|
|
|
2013-07-09 19:21:36 -04:00
|
|
|
name = req.dependency.name
|
|
|
|
|
|
|
|
@all[name].each do |uri, n|
|
2018-11-21 05:20:47 -05:00
|
|
|
if req.match? n, @prerelease
|
2013-11-18 19:34:13 -05:00
|
|
|
res << Gem::Resolver::IndexSpecification.new(
|
2013-07-09 19:21:36 -04:00
|
|
|
self, n.name, n.version, uri, n.platform)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
res
|
|
|
|
end
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def pretty_print(q) # :nodoc:
|
2013-11-30 18:27:52 -05:00
|
|
|
q.group 2, '[IndexSet', ']' do
|
|
|
|
q.breakable
|
|
|
|
q.text 'sources:'
|
|
|
|
q.breakable
|
|
|
|
q.pp @f.sources
|
|
|
|
|
|
|
|
q.breakable
|
|
|
|
q.text 'specs:'
|
|
|
|
|
|
|
|
q.breakable
|
|
|
|
|
|
|
|
names = @all.values.map do |tuples|
|
|
|
|
tuples.map do |_, tuple|
|
|
|
|
tuple.full_name
|
|
|
|
end
|
|
|
|
end.flatten
|
|
|
|
|
|
|
|
q.seplist names do |name|
|
|
|
|
q.text name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-07-09 19:21:36 -04:00
|
|
|
end
|