Class: Chef::Cookbook::Chefignore
- Defined in:
- lib/chef/cookbook/chefignore.rb
Constant Summary collapse
- COMMENTS_AND_WHITESPACE =
/^\w*(?:#.*)?$/
Instance Attribute Summary collapse
-
#ignores ⇒ Object
readonly
Returns the value of attribute ignores.
Instance Method Summary collapse
- #ignored?(file_name) ⇒ Boolean
-
#initialize(ignore_file_or_repo) ⇒ Chefignore
constructor
A new instance of Chefignore.
- #remove_ignores_from(file_list) ⇒ Object
Constructor Details
#initialize(ignore_file_or_repo) ⇒ Chefignore
Returns a new instance of Chefignore.
27 28 29 30 |
# File 'lib/chef/cookbook/chefignore.rb', line 27 def initialize(ignore_file_or_repo) @ignore_file = find_ignore_file(ignore_file_or_repo) @ignores = parse_ignore_file end |
Instance Attribute Details
#ignores ⇒ Object (readonly)
Returns the value of attribute ignores.
25 26 27 |
# File 'lib/chef/cookbook/chefignore.rb', line 25 def ignores @ignores end |
Instance Method Details
#ignored?(file_name) ⇒ Boolean
38 39 40 |
# File 'lib/chef/cookbook/chefignore.rb', line 38 def ignored?(file_name) @ignores.any? {|glob| File.fnmatch?(glob, file_name)} end |
#remove_ignores_from(file_list) ⇒ Object
32 33 34 35 36 |
# File 'lib/chef/cookbook/chefignore.rb', line 32 def remove_ignores_from(file_list) Array(file_list).inject([]) do |unignored, file| ignored?(file) ? unignored : unignored << file end end |