summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-01-23 12:11:31 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2017-01-23 12:19:29 -0800
commit000104cbdfede023ddd65e21aad89cefee4f8d59 (patch)
tree8215ba9579f36412ae80fa2127d544bcbd2184db /lib
parentdee9ffe7583cad4a5b517bfd572118cd0fcc1501 (diff)
downloadchef-zero-000104cbdfede023ddd65e21aad89cefee4f8d59.tar.gz
favor metadata.json over metadata.rb
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib')
-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|