From fcbf63e62c627deae76c1b8cb8c0876c536ed811 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 16 Mar 2020 18:49:26 +0900 Subject: Fresh start --- jni/ruby/lib/rubygems/resolver/composed_set.rb | 66 ++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 jni/ruby/lib/rubygems/resolver/composed_set.rb (limited to 'jni/ruby/lib/rubygems/resolver/composed_set.rb') diff --git a/jni/ruby/lib/rubygems/resolver/composed_set.rb b/jni/ruby/lib/rubygems/resolver/composed_set.rb new file mode 100644 index 0000000..5b08f12 --- /dev/null +++ b/jni/ruby/lib/rubygems/resolver/composed_set.rb @@ -0,0 +1,66 @@ +## +# 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. + +class Gem::Resolver::ComposedSet < Gem::Resolver::Set + + attr_reader :sets # :nodoc: + + ## + # Creates a new ComposedSet containing +sets+. Use + # Gem::Resolver::compose_sets instead. + + def initialize *sets + super() + + @sets = sets + end + + ## + # When +allow_prerelease+ is set to +true+ prereleases gems are allowed to + # match dependencies. + + def prerelease= allow_prerelease + super + + sets.each do |set| + set.prerelease = allow_prerelease + end + end + + ## + # Sets the remote network access for all composed sets. + + def remote= remote + super + + @sets.each { |set| set.remote = remote } + end + + def errors + @errors + @sets.map { |set| set.errors }.flatten + end + + ## + # Finds all specs matching +req+ in all sets. + + def find_all req + @sets.map do |s| + s.find_all req + end.flatten + end + + ## + # Prefetches +reqs+ in all sets. + + def prefetch reqs + @sets.each { |s| s.prefetch(reqs) } + end + +end + -- cgit v1.2.3