aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dependencies.rb
diff options
context:
space:
mode:
authorJack Nagel2014-07-03 14:50:57 -0500
committerJack Nagel2014-07-03 14:50:57 -0500
commit618b894c3e9cf6b0bdb2f46fd258b27d863d1373 (patch)
treecb276cef36c3b0da43d4e0d98c42a4166cbb2b22 /Library/Homebrew/dependencies.rb
parent3ad6fc6636a2ae30ab1060fa5c77bb26d828ae6d (diff)
downloadbrew-618b894c3e9cf6b0bdb2f46fd258b27d863d1373.tar.bz2
Replace ComparableSet with a Requirements collection
Diffstat (limited to 'Library/Homebrew/dependencies.rb')
-rw-r--r--Library/Homebrew/dependencies.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/Library/Homebrew/dependencies.rb b/Library/Homebrew/dependencies.rb
index 0e0637c81..96a4106b5 100644
--- a/Library/Homebrew/dependencies.rb
+++ b/Library/Homebrew/dependencies.rb
@@ -52,3 +52,28 @@ class Dependencies
end
alias_method :eql?, :==
end
+
+class Requirements
+ include Enumerable
+
+ def initialize(*args)
+ @reqs = Set.new(*args)
+ end
+
+ def each(*args, &block)
+ @reqs.each(*args, &block)
+ end
+
+ def <<(other)
+ if Comparable === other
+ @reqs.grep(other.class) do |req|
+ return self if req > other
+ @reqs.delete(req)
+ end
+ end
+ @reqs << other
+ self
+ end
+
+ alias_method :to_ary, :to_a
+end