diff options
-rw-r--r-- | lib/chef_zero/chef_data/cookbook_data.rb | 10 |
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| |