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
|
2013-07-09 19:21:36 -04:00
|
|
|
|
2013-11-10 12:51:40 -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 =
|
|
|
|
if source then
|
|
|
|
sources = Gem::SourceList.from [source]
|
|
|
|
|
|
|
|
Gem::SpecFetcher.new sources
|
|
|
|
else
|
|
|
|
Gem::SpecFetcher.fetcher
|
|
|
|
end
|
2013-07-09 19:21:36 -04:00
|
|
|
|
|
|
|
@all = Hash.new { |h,k| h[k] = [] }
|
|
|
|
|
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+.
|
|
|
|
|
|
|
|
def find_all req
|
|
|
|
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|
|
2014-09-13 23:30:02 -04:00
|
|
|
if req.match? n, @prerelease then
|
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
|
|
|
|
|
2013-11-30 18:27:52 -05:00
|
|
|
def pretty_print q # :nodoc:
|
|
|
|
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
|
|
|
|
|