Module: PuppetRakeTasks::DepChecker::Resolver::Ignores
- Extended by:
- Helpers
- Included in:
- PuppetRakeTasks::DepChecker::Resolver
- Defined in:
- lib/puppet_rake_tasks/depchecker/ignores.rb
Overview
Deal with management of the ignore rules you can set. You can either set all rules in one go using #ignores= or add one by one using the #ignore method.
Reference:
When referring to the 'simple name' of a puppet module, use the name without author/ in front.
You can not have a module with the same name installed in your tree anyhow.
Instance Method Summary collapse
-
#collect_ignores_for_module(modulename) ⇒ Array
private
Array with all ignores that apply to a certain puppet module.
- #ignore(for_module, expr) ⇒ Object
-
#ignores ⇒ Hash
Returns all configured ignore rules.
-
#ignores=(ignores) ⇒ Object
Configure all ignore rules at once by setting a single hash.
-
#ignores_for_module(modulename) ⇒ Object
Returns ignore rules that might apply to the modulename and caches the result.
-
#ignores_matches_incident(modulename, incident) ⇒ Object
Loop over ignores for a modulename and check if it matches the incident.
Methods included from Helpers
compare_values, normalize_path, swat_hash
Instance Method Details
#collect_ignores_for_module(modulename) ⇒ Array (private)
Returns array with all ignores that apply to a certain puppet module.
93 94 95 96 97 98 99 |
# File 'lib/puppet_rake_tasks/depchecker/ignores.rb', line 93 def collect_ignores_for_module(modulename) tmp_ignores = [] ignores.each do |k, i| tmp_ignores += i if (k.is_a?(String) && k == modulename) || (k.is_a?(Regexp) && modulename =~ k) end tmp_ignores end |
#ignore(for_module, expr) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/puppet_rake_tasks/depchecker/ignores.rb', line 50 def ignore(for_module, expr) # reset cached ignores matching modules (@ignores_for_module ||= {})[for_module] = nil # initialize if not exists (@ignores ||= {})[for_module] ||= [] @ignores[for_module] << expr end |
#ignores ⇒ Hash
Returns all configured ignore rules.
61 62 63 |
# File 'lib/puppet_rake_tasks/depchecker/ignores.rb', line 61 def ignores @ignores ||= {} end |
#ignores=(ignores) ⇒ Object
Configure all ignore rules at once by setting a single hash. This clears the cached ignore rules for modules.
43 44 45 46 |
# File 'lib/puppet_rake_tasks/depchecker/ignores.rb', line 43 def ignores=(ignores) @ignores = ignores @ignores_for_module = {} end |
#ignores_for_module(modulename) ⇒ Object
Returns ignore rules that might apply to the modulename and caches the result.
67 68 69 70 |
# File 'lib/puppet_rake_tasks/depchecker/ignores.rb', line 67 def ignores_for_module(modulename) @ignores_for_module[modulename] ||= collect_ignores_for_module(modulename) if (@ignores_for_module ||= {})[modulename].nil? @ignores_for_module[modulename] end |
#ignores_matches_incident(modulename, incident) ⇒ Object
Loop over ignores for a modulename and check if it matches the incident.
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/puppet_rake_tasks/depchecker/ignores.rb', line 75 def ignores_matches_incident(modulename, incident) loop_ignores = ignores_for_module(modulename) # Look for a match, return true immediately, otherwise, false loop_ignores.each do |ign| this_ignore = true ign.each_key do |k| compare = Helpers.compare_values(ign[k], incident[k]) this_ignore = false unless compare end return true if this_ignore end false end |