diff options
| author | Jack Nagel | 2014-07-03 14:50:57 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-07-03 14:50:57 -0500 |
| commit | 618b894c3e9cf6b0bdb2f46fd258b27d863d1373 (patch) | |
| tree | cb276cef36c3b0da43d4e0d98c42a4166cbb2b22 /Library/Homebrew/dependencies.rb | |
| parent | 3ad6fc6636a2ae30ab1060fa5c77bb26d828ae6d (diff) | |
| download | brew-618b894c3e9cf6b0bdb2f46fd258b27d863d1373.tar.bz2 | |
Replace ComparableSet with a Requirements collection
Diffstat (limited to 'Library/Homebrew/dependencies.rb')
| -rw-r--r-- | Library/Homebrew/dependencies.rb | 25 |
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 |
