summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2013-06-11 17:47:43 -0700
committerJohn Keiser <jkeiser@opscode.com>2013-06-11 17:48:12 -0700
commit8d77a1b2a770c8712626a28c366789552365d95c (patch)
tree72f14bd755277f9a993c18edd9256224a54c60b6
parent1b9ce455ccb8ff95a9684fbe52b7c41843cc10a2 (diff)
downloadchef-zero-8d77a1b2a770c8712626a28c366789552365d95c.tar.gz
Pass __FILE__ to metadata.rb
-rw-r--r--lib/chef_zero/cookbook_data.rb14
1 files changed, 13 insertions, 1 deletions
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