Class: Babushka::SystemMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/babushka/system_matcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#flavourObject (readonly)

Returns the value of attribute flavour.



3
4
5
# File 'lib/babushka/system_matcher.rb', line 3

def flavour
  @flavour
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/babushka/system_matcher.rb', line 3

def name
  @name
end

#pkg_helper_keyObject (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

#systemObject (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

#listObject



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

Returns:

  • (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