diff options
-rw-r--r-- | lib/chef/cookbook/cookbook_version_loader.rb | 18 | ||||
-rw-r--r-- | lib/chef/cookbook_version.rb | 4 | ||||
-rw-r--r-- | spec/unit/cookbook/cookbook_version_loader_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/cookbook_version_spec.rb | 8 |
4 files changed, 16 insertions, 16 deletions
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb index b9fa5dfa29..0e3fb2ef72 100644 --- a/lib/chef/cookbook/cookbook_version_loader.rb +++ b/lib/chef/cookbook/cookbook_version_loader.rb @@ -43,7 +43,7 @@ class Chef @relative_path = /#{Regexp.escape(@cookbook_path)}\/(.+)$/ @metadata_loaded = false @cookbook_settings = { - :all_unignored_files => {}, + :all_files => {}, :attribute_filenames => {}, :definition_filenames => {}, :recipe_filenames => {}, @@ -79,13 +79,13 @@ class Chef # re-raise any exception that occurred when reading the metadata raise_metadata_error! - load_all_unignored_files + load_all_files # TODO: # 1. Can we safely pick out the segment files with fnmatch against the - # file names in all_unignored_files (?) + # file names in all_files (?) # 2. If so, can we avoid running chefignore twice by running it against - # all_unignored_files before segmenting? + # all_files before segmenting? # # See: https://shane.io/2014/07/13/sobbing-with-ruby-file-globbing.html @@ -132,7 +132,7 @@ class Chef return nil if empty? Chef::CookbookVersion.new(cookbook_name, *cookbook_paths).tap do |c| - c.all_unignored_files = cookbook_settings[:all_unignored_files].values + c.all_files = cookbook_settings[:all_files].values c.attribute_filenames = cookbook_settings[:attribute_filenames].values c.definition_filenames = cookbook_settings[:definition_filenames].values c.recipe_filenames = cookbook_settings[:recipe_filenames].values @@ -224,7 +224,7 @@ class Chef @chefignore ||= Chefignore.new(File.basename(cookbook_path)) end - def load_all_unignored_files + def load_all_files # List all directories that are not dotdirs, then list everything in # those, *including* dotfiles and dotdirs. # Finally, list all the _files_ at the root, including dotfiles, and @@ -235,11 +235,11 @@ class Chef Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(dir), "**/*"), File::FNM_DOTMATCH).each do |file| name = Chef::Util::PathHelper.relative_path_from(@cookbook_path, file) - cookbook_settings[:all_unignored_files][name] = file + cookbook_settings[:all_files][name] = file end end load_root_files - cookbook_settings[:all_unignored_files].merge!(cookbook_settings[:root_filenames]) + cookbook_settings[:all_files].merge!(cookbook_settings[:root_filenames]) end def load_root_files @@ -283,7 +283,7 @@ class Chef # always enabled. def select_files_by_glob(pattern, option = 0) combined_opts = option | File::FNM_PATHNAME - cookbook_settings[:all_unignored_files].values.select do |path| + cookbook_settings[:all_files].values.select do |path| File.fnmatch?(pattern, path, combined_opts) end end diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb index d9e9897a06..2857d8098e 100644 --- a/lib/chef/cookbook_version.rb +++ b/lib/chef/cookbook_version.rb @@ -40,7 +40,7 @@ class Chef COOKBOOK_SEGMENTS = [ :resources, :providers, :recipes, :definitions, :libraries, :attributes, :files, :templates, :root_files ] - attr_accessor :all_unignored_files + attr_accessor :all_files attr_accessor :root_paths attr_accessor :definition_filenames @@ -130,7 +130,7 @@ class Chef @metadata_filenames = Array.new @root_filenames = Array.new - @all_unignored_files = Array.new + @all_files = Array.new # deprecated @status = :ready diff --git a/spec/unit/cookbook/cookbook_version_loader_spec.rb b/spec/unit/cookbook/cookbook_version_loader_spec.rb index 161b3d0f3d..0c4814021c 100644 --- a/spec/unit/cookbook/cookbook_version_loader_spec.rb +++ b/spec/unit/cookbook/cookbook_version_loader_spec.rb @@ -74,7 +74,7 @@ describe Chef::Cookbook::CookbookVersionLoader do end it "loads all unignored files, even if they don't match a segment type" do - expect(loaded_cookbook.all_unignored_files).to include(full_path("/spec/spec_helper.rb")) + expect(loaded_cookbook.all_files).to include(full_path("/spec/spec_helper.rb")) end it "should load the metadata for the cookbook" do diff --git a/spec/unit/cookbook_version_spec.rb b/spec/unit/cookbook_version_spec.rb index a74786c1d1..7def2f5749 100644 --- a/spec/unit/cookbook_version_spec.rb +++ b/spec/unit/cookbook_version_spec.rb @@ -57,8 +57,8 @@ describe Chef::CookbookVersion do expect(cookbook_version.metadata_filenames).to be_empty end - it "has an empty set of all_unignored_files" do - expect(cookbook_version.all_unignored_files).to be_empty + it "has an empty set of all_files" do + expect(cookbook_version.all_files).to be_empty end it "is not frozen" do @@ -82,7 +82,7 @@ describe Chef::CookbookVersion do let(:cookbook_paths_by_type) do { # Dunno if the paths here are representitive of what is set by CookbookLoader... - all_unignored_files: Dir[File.join(cookbook_root, "**", "*.rb")], + all_files: Dir[File.join(cookbook_root, "**", "*.rb")], attribute_filenames: Dir[File.join(cookbook_root, "attributes", "**", "*.rb")], definition_filenames: Dir[File.join(cookbook_root, "definitions", "**", "*.rb")], file_filenames: Dir[File.join(cookbook_root, "files", "**", "*.tgz")], @@ -169,7 +169,7 @@ describe Chef::CookbookVersion do let(:cookbook_paths_by_type) do { # Dunno if the paths here are representitive of what is set by CookbookLoader... - all_unignored_files: Dir[File.join(cookbook_root, "**", "*.rb")], + all_files: Dir[File.join(cookbook_root, "**", "*.rb")], attribute_filenames: Dir[File.join(cookbook_root, "attributes", "**", "*.rb")], definition_filenames: Dir[File.join(cookbook_root, "definitions", "**", "*.rb")], file_filenames: Dir[File.join(cookbook_root, "files", "**", "*.*")], |