Class: Ridley::Chef::Chefignore
- Inherits:
-
Object
- Object
- Ridley::Chef::Chefignore
- Defined in:
- lib/ridley/chef/chefignore.rb
Overview
Borrowed and modified from: https://raw.github.com/opscode/chef/62f9b0e3be8e22eef092163c331b7d3f8d350f94/lib/chef/cookbook/chefignore.rb
- Copyright
-
Copyright © 2011 Opscode, Inc.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Constant Summary collapse
- FILENAME =
"chefignore".freeze
- COMMENTS_AND_WHITESPACE =
/^\s*(?:#.*)?$/
Instance Attribute Summary collapse
-
#ignores ⇒ Object
readonly
Returns the value of attribute ignores.
Class Method Summary collapse
-
.find_relative_to(path) ⇒ String?
Traverse a path in relative context to find a Chefignore file.
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.
39 40 41 42 |
# File 'lib/ridley/chef/chefignore.rb', line 39 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.
37 38 39 |
# File 'lib/ridley/chef/chefignore.rb', line 37 def ignores @ignores end |
Class Method Details
Instance Method Details
#ignored?(file_name) ⇒ Boolean
50 51 52 |
# File 'lib/ridley/chef/chefignore.rb', line 50 def ignored?(file_name) @ignores.any? { |glob| File.fnmatch?(glob, file_name) } end |
#remove_ignores_from(file_list) ⇒ Object
44 45 46 47 48 |
# File 'lib/ridley/chef/chefignore.rb', line 44 def remove_ignores_from(file_list) Array(file_list).inject([]) do |unignored, file| ignored?(file) ? unignored : unignored << file end end |