lib/ridley/chef/cookbook.rb in ridley-0.9.0 vs lib/ridley/chef/cookbook.rb in ridley-0.9.1
- old
+ new
@@ -94,10 +94,11 @@
resources: Array.new,
providers: Array.new,
root_files: Array.new
)
@frozen = false
+ @chefignore = Ridley::Chef::Chefignore.new(@path)
load_files
end
# @return [Hash]
@@ -205,12 +206,17 @@
[self.cookbook_name, self.version] <=> [other.cookbook_name, other.version]
end
private
+ # @return [Array]
attr_reader :files
+ # @return [Ridley::Chef::Chefignore]
+ attr_reader :chefignore
+ def_delegator :chefignore, :ignored?
+
def load_files
load_shallow(:recipes, 'recipes', '*.rb')
load_shallow(:definitions, 'definitions', '*.rb')
load_shallow(:libraries, 'libraries', '*.rb')
load_shallow(:attributes, 'attributes', '*.rb')
@@ -223,10 +229,11 @@
def load_root
[].tap do |files|
Dir.glob(path.join('*'), File::FNM_DOTMATCH).each do |file|
next if File.directory?(file)
+ next if ignored?(file)
@files << file
@manifest[:root_files] << file_metadata(:root_files, file)
end
end
end
@@ -234,18 +241,20 @@
def load_recursively(category, category_dir, glob)
[].tap do |files|
file_spec = path.join(category_dir, '**', glob)
Dir.glob(file_spec, File::FNM_DOTMATCH).each do |file|
next if File.directory?(file)
+ next if ignored?(file)
@files << file
@manifest[category] << file_metadata(category, file)
end
end
end
def load_shallow(category, *path_glob)
[].tap do |files|
Dir[path.join(*path_glob)].each do |file|
+ next if ignored?(file)
@files << file
@manifest[category] << file_metadata(category, file)
end
end
end