brew/Library/Homebrew/dependencies.rb

66 lines
939 B
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: false
# frozen_string_literal: true
require "delegate"
2020-07-30 12:59:01 -04:00
require "cask_dependent"
# A collection of dependencies.
#
# @api private
class Dependencies < SimpleDelegator
def initialize(*args)
super(args)
end
alias eql? ==
2013-05-10 23:45:06 -05:00
def optional
select(&:optional?)
end
def recommended
select(&:recommended?)
end
def build
select(&:build?)
end
def required
select(&:required?)
end
def default
build + required + recommended
end
def inspect
"#<#{self.class.name}: #{to_a}>"
end
end
# A collection of requirements.
#
# @api private
class Requirements < SimpleDelegator
def initialize(*args)
super(Set.new(args))
end
def <<(other)
2016-09-20 22:03:08 +02:00
if other.is_a?(Comparable)
grep(other.class) do |req|
return self if req > other
2018-09-17 02:45:00 +02:00
delete(req)
end
end
super
self
end
def inspect
"#<#{self.class.name}: {#{to_a.join(", ")}}>"
end
end