Class: Babushka::SystemMatcher
Instance Attribute Summary collapse
-
#flavour ⇒ Object
readonly
Returns the value of attribute flavour.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pkg_helper_key ⇒ Object
readonly
Returns the value of attribute pkg_helper_key.
-
#system ⇒ Object
readonly
Returns the value of attribute system.
Instance Method Summary collapse
- #differentiator_for(specs) ⇒ Object
-
#initialize(system, flavour, name, pkg_helper_key) ⇒ SystemMatcher
constructor
A new instance of SystemMatcher.
- #list ⇒ Object
- #matches?(specs) ⇒ Boolean
Constructor Details
#initialize(system, flavour, name, pkg_helper_key) ⇒ SystemMatcher
Returns a new instance of SystemMatcher.
5 6 7 |
# File 'lib/babushka/system_matcher.rb', line 5 def initialize system, flavour, name, pkg_helper_key @system, @flavour, @name, @pkg_helper_key = system, flavour, name, pkg_helper_key end |
Instance Attribute Details
#flavour ⇒ Object (readonly)
Returns the value of attribute flavour.
3 4 5 |
# File 'lib/babushka/system_matcher.rb', line 3 def flavour @flavour end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/babushka/system_matcher.rb', line 3 def name @name end |
#pkg_helper_key ⇒ Object (readonly)
Returns the value of attribute pkg_helper_key.
3 4 5 |
# File 'lib/babushka/system_matcher.rb', line 3 def pkg_helper_key @pkg_helper_key end |
#system ⇒ Object (readonly)
Returns the value of attribute system.
3 4 5 |
# File 'lib/babushka/system_matcher.rb', line 3 def system @system end |
Instance Method Details
#differentiator_for(specs) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/babushka/system_matcher.rb', line 19 def differentiator_for specs [*specs].map {|spec| first_nonmatch_for spec }.sort_by {|spec| [:system, :flavour, :name].index spec }.compact.last end |
#list ⇒ Object
9 10 11 |
# File 'lib/babushka/system_matcher.rb', line 9 def list [name, flavour, pkg_helper_key, system, :all].compact end |
#matches?(specs) ⇒ Boolean
13 14 15 16 17 |
# File 'lib/babushka/system_matcher.rb', line 13 def matches? specs # TODO: shouldn't this just be: # (list & [*specs]).any? [*specs].any? {|spec| first_nonmatch_for(spec).nil? } end |