summaryrefslogtreecommitdiff
path: root/jni/ruby/lib/rubygems/resolver/composed_set.rb
diff options
context:
space:
mode:
authorJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-16 18:49:26 +0900
committerJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-30 00:39:06 +0900
commitfcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch)
tree64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/lib/rubygems/resolver/composed_set.rb
Fresh start
Diffstat (limited to 'jni/ruby/lib/rubygems/resolver/composed_set.rb')
-rw-r--r--jni/ruby/lib/rubygems/resolver/composed_set.rb66
1 files changed, 66 insertions, 0 deletions
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
+