2016-02-01 07:43:26 -05:00
|
|
|
##
|
|
|
|
# The SourceSet chooses the best available method to query a remote index.
|
|
|
|
#
|
|
|
|
# Kind off like BestSet but filters the sources for gems
|
|
|
|
|
|
|
|
class Gem::Resolver::SourceSet < Gem::Resolver::Set
|
|
|
|
##
|
|
|
|
# Creates a SourceSet for the given +sources+ or Gem::sources if none are
|
|
|
|
# specified. +sources+ must be a Gem::SourceList.
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super()
|
|
|
|
|
|
|
|
@links = {}
|
|
|
|
@sets = {}
|
|
|
|
end
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def find_all(req) # :nodoc:
|
2016-02-01 07:43:26 -05:00
|
|
|
if set = get_set(req.dependency.name)
|
|
|
|
set.find_all req
|
|
|
|
else
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# potentially no-op
|
2018-11-21 05:20:47 -05:00
|
|
|
def prefetch(reqs) # :nodoc:
|
2016-02-01 07:43:26 -05:00
|
|
|
reqs.each do |req|
|
|
|
|
if set = get_set(req.dependency.name)
|
|
|
|
set.prefetch reqs
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def add_source_gem(name, source)
|
2016-02-01 07:43:26 -05:00
|
|
|
@links[name] = source
|
|
|
|
end
|
|
|
|
|
2018-10-21 20:27:02 -04:00
|
|
|
private
|
2016-02-01 07:43:26 -05:00
|
|
|
|
|
|
|
def get_set(name)
|
|
|
|
link = @links[name]
|
|
|
|
@sets[link] ||= Gem::Source.new(link).dependency_resolver_set if link
|
|
|
|
end
|
|
|
|
end
|