Class: Chef::Cookbook::Chefignore
- Inherits:
-
Object
- Object
- Chef::Cookbook::Chefignore
- Defined in:
- lib/chef/cookbook/chefignore.rb
Constant Summary collapse
- COMMENTS_AND_WHITESPACE =
/^\s*(?:#.*)?$/.freeze
Instance Attribute Summary collapse
-
#ignores ⇒ Object
readonly
Returns the value of attribute ignores.
Instance Method Summary collapse
-
#ignored?(file_name) ⇒ Boolean
Is the file ignored or not.
-
#initialize(ignore_file_or_repo) ⇒ Chefignore
constructor
A new instance of Chefignore.
-
#remove_ignores_from(file_list) ⇒ Array
List of cookbook files with chefignore files removed.
Constructor Details
#initialize(ignore_file_or_repo) ⇒ Chefignore
Returns a new instance of Chefignore.
26 27 28 29 30 31 |
# File 'lib/chef/cookbook/chefignore.rb', line 26 def initialize(ignore_file_or_repo) # Check the 'ignore_file_or_repo' path first and then look in the parent directories till root # to handle both the chef repo cookbook layout and a standalone cookbook @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.
24 25 26 |
# File 'lib/chef/cookbook/chefignore.rb', line 24 def ignores @ignores end |
Instance Method Details
#ignored?(file_name) ⇒ Boolean
Returns is the file ignored or not.
43 44 45 |
# File 'lib/chef/cookbook/chefignore.rb', line 43 def ignored?(file_name) @ignores.any? { |glob| File.fnmatch?(glob, file_name) } end |
#remove_ignores_from(file_list) ⇒ Array
Returns list of cookbook files with chefignore files removed.
35 36 37 38 39 |
# File 'lib/chef/cookbook/chefignore.rb', line 35 def remove_ignores_from(file_list) Array(file_list).inject([]) do |unignored, file| ignored?(file) ? unignored : unignored << file end end |