summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-01-23 12:36:07 -0800
committerGitHub <noreply@github.com>2017-01-23 12:36:07 -0800
commit36c1cffe36e8582d57f77166a6a8fcc83a74aa1e (patch)
tree8215ba9579f36412ae80fa2127d544bcbd2184db
parentdee9ffe7583cad4a5b517bfd572118cd0fcc1501 (diff)
parent000104cbdfede023ddd65e21aad89cefee4f8d59 (diff)
downloadchef-zero-36c1cffe36e8582d57f77166a6a8fcc83a74aa1e.tar.gz
Merge pull request #251 from chef/lcg/favor-metadta-rb
favor metadata.json over metadata.rb
-rw-r--r--lib/chef_zero/chef_data/cookbook_data.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/chef_zero/chef_data/cookbook_data.rb b/lib/chef_zero/chef_data/cookbook_data.rb
index 1a0f473..f69829a 100644
--- a/lib/chef_zero/chef_data/cookbook_data.rb
+++ b/lib/chef_zero/chef_data/cookbook_data.rb
@@ -29,18 +29,16 @@ module ChefZero
def self.metadata_from(directory, name, version, recipe_names)
metadata = PretendCookbookMetadata.new(PretendCookbook.new(name, recipe_names))
- # If both .rb and .json exist, read .rb
- # TODO if recipes has 3 recipes in it, and the Ruby/JSON has only one, should
- # the resulting recipe list have 1, or 3-4 recipes in it?
- if has_child(directory, "metadata.rb")
+ # If both .rb and .json exist, read .json
+ if has_child(directory, "metadata.json")
+ metadata.from_json(read_file(directory, "metadata.json"))
+ elsif has_child(directory, "metadata.rb")
begin
file = filename(directory, "metadata.rb") || "(#{name}/metadata.rb)"
metadata.instance_eval(read_file(directory, "metadata.rb"), file)
rescue
ChefZero::Log.error("Error loading cookbook #{name}: #{$!}\n #{$!.backtrace.join("\n ")}")
end
- elsif has_child(directory, "metadata.json")
- metadata.from_json(read_file(directory, "metadata.json"))
end
result = {}
metadata.to_hash.each_pair do |key, value|