From 8d77a1b2a770c8712626a28c366789552365d95c Mon Sep 17 00:00:00 2001 From: John Keiser Date: Tue, 11 Jun 2013 17:47:43 -0700 Subject: Pass __FILE__ to metadata.rb --- lib/chef_zero/cookbook_data.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/chef_zero/cookbook_data.rb b/lib/chef_zero/cookbook_data.rb index 6b18695..fbfd964 100644 --- a/lib/chef_zero/cookbook_data.rb +++ b/lib/chef_zero/cookbook_data.rb @@ -32,7 +32,11 @@ module ChefZero # 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') - metadata.instance_eval(read_file(directory, 'metadata.rb')) + begin + metadata.instance_eval(read_file(directory, 'metadata.rb'), File.join(filename(directory), 'metadata.rb')) + rescue + ChefZero::Log.error("Error loading cookbook #{name}: #{$!}") + end elsif has_child(directory, 'metadata.json') metadata.from_json(read_file(directory, 'metadata.json')) end @@ -161,6 +165,14 @@ module ChefZero end end + def self.filename(directory) + if directory.respond_to?(:file_path) + directory.file_path + else + nil + end + end + def self.get_directory(directory, name) if directory.is_a?(Hash) directory[name].is_a?(Hash) ? directory[name] : nil -- cgit v1.2.1