2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2013-11-21 18:27:30 -05:00
|
|
|
##
|
|
|
|
# A ComposedSet allows multiple sets to be queried like a single set.
|
|
|
|
#
|
|
|
|
# To create a composed set with any number of sets use:
|
|
|
|
#
|
|
|
|
# Gem::Resolver.compose_sets set1, set2
|
|
|
|
#
|
|
|
|
# This method will eliminate nesting of composed sets.
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
class Gem::Resolver::ComposedSet < Gem::Resolver::Set
|
2013-11-10 12:51:40 -05:00
|
|
|
attr_reader :sets # :nodoc:
|
2013-07-09 19:21:36 -04:00
|
|
|
|
2013-11-21 18:27:30 -05:00
|
|
|
##
|
|
|
|
# Creates a new ComposedSet containing +sets+. Use
|
|
|
|
# Gem::Resolver::compose_sets instead.
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def initialize(*sets)
|
2014-02-03 19:48:31 -05:00
|
|
|
super()
|
|
|
|
|
2013-07-09 19:21:36 -04:00
|
|
|
@sets = sets
|
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
##
|
|
|
|
# When +allow_prerelease+ is set to +true+ prereleases gems are allowed to
|
|
|
|
# match dependencies.
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def prerelease=(allow_prerelease)
|
2014-09-13 23:30:02 -04:00
|
|
|
super
|
|
|
|
|
|
|
|
sets.each do |set|
|
|
|
|
set.prerelease = allow_prerelease
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-02-03 19:48:31 -05:00
|
|
|
##
|
|
|
|
# Sets the remote network access for all composed sets.
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def remote=(remote)
|
2014-02-03 19:48:31 -05:00
|
|
|
super
|
|
|
|
|
2020-06-10 13:46:05 -04:00
|
|
|
@sets.each {|set| set.remote = remote }
|
2014-02-03 19:48:31 -05:00
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def errors
|
2020-06-10 13:46:05 -04:00
|
|
|
@errors + @sets.map {|set| set.errors }.flatten
|
2014-09-13 23:30:02 -04:00
|
|
|
end
|
|
|
|
|
2013-11-21 18:27:30 -05:00
|
|
|
##
|
|
|
|
# Finds all specs matching +req+ in all sets.
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def find_all(req)
|
2013-11-22 13:53:21 -05:00
|
|
|
@sets.map do |s|
|
|
|
|
s.find_all req
|
|
|
|
end.flatten
|
2013-07-09 19:21:36 -04:00
|
|
|
end
|
|
|
|
|
2013-11-21 18:27:30 -05:00
|
|
|
##
|
|
|
|
# Prefetches +reqs+ in all sets.
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def prefetch(reqs)
|
2020-06-10 13:46:05 -04:00
|
|
|
@sets.each {|s| s.prefetch(reqs) }
|
2013-07-09 19:21:36 -04:00
|
|
|
end
|
|
|
|
end
|