diff options
author | danielsdeleo <dan@getchef.com> | 2014-08-05 15:49:30 -0700 |
---|---|---|
committer | danielsdeleo <dan@getchef.com> | 2014-08-12 11:03:09 -0700 |
commit | 902c600e497912e81cd187f7716d31d5575cb03f (patch) | |
tree | 636873892277c6fb1be84436e6bea29152bc17cb /lib/chef | |
parent | 7545eda303bbb6034a0a2397e1a510b19bdd5e9b (diff) | |
download | chef-902c600e497912e81cd187f7716d31d5575cb03f.tar.gz |
Encapsulate cookbook loader map with methods
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/cookbook_loader.rb | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/chef/cookbook_loader.rb b/lib/chef/cookbook_loader.rb index cac5548565..d569cdd008 100644 --- a/lib/chef/cookbook_loader.rb +++ b/lib/chef/cookbook_loader.rb @@ -79,7 +79,7 @@ class Chef return nil unless @loaders_by_name.key?(cookbook_name.to_s) - @loaders_by_name[cookbook_name.to_s].each do |loader| + cookbook_loaders_for(cookbook_name).each do |loader| loader.load next if loader.empty? @@ -149,12 +149,7 @@ class Chef repo_path = File.dirname(cookbook_path) @chefignores[repo_path] ||= Cookbook::Chefignore.new(repo_path) loader = Cookbook::CookbookVersionLoader.new(cookbook_path, @chefignores[repo_path]) - - cookbook_name = loader.cookbook_name - - # TODO: wrap @loaders_by_name so string keys are encapsulated - @loaders_by_name[cookbook_name.to_s] ||= [] - @loaders_by_name[cookbook_name.to_s] << loader + add_cookbook_loader(loader) end def all_directories_in_repo_paths @@ -171,5 +166,17 @@ class Chef end end + def add_cookbook_loader(loader) + cookbook_name = loader.cookbook_name + + @loaders_by_name[cookbook_name.to_s] ||= [] + @loaders_by_name[cookbook_name.to_s] << loader + loader + end + + def cookbook_loaders_for(cookbook_name) + @loaders_by_name[cookbook_name.to_s] + end + end end |