Module: ChefConfig::Mixin::FuzzyHostnameMatcher

Included in:
Config
Defined in:
lib/chef-config/mixin/fuzzy_hostname_matcher.rb

Instance Method Summary collapse

Instance Method Details

#fuzzy_hostname_match?(hostname, match) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
35
# File 'lib/chef-config/mixin/fuzzy_hostname_matcher.rb', line 31

def fuzzy_hostname_match?(hostname, match)
  # Do greedy matching by adding wildcard if it is not specified
  match = "*" + match if !match.start_with?("*")
  Fuzzyurl.matches?(Fuzzyurl.mask(hostname: match), hostname)
end

#fuzzy_hostname_match_any?(hostname, matches) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
# File 'lib/chef-config/mixin/fuzzy_hostname_matcher.rb', line 23

def fuzzy_hostname_match_any?(hostname, matches)
  return matches.to_s.split(/\s*,\s*/).compact.any? do |m|
    fuzzy_hostname_match?(hostname, m)
  end if (hostname != nil) && (matches != nil)

  false
end