summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2013-05-19 10:51:14 -0700
committerJohn Keiser <jkeiser@opscode.com>2013-05-19 10:51:14 -0700
commitc6afab3e124d8e36a690d30617b9b238e96c4741 (patch)
treec78d8c162d9337c6898e574fe0e2d361159bc07b
parenteb915b70d128bedf331396f2909c6ef7161f86b8 (diff)
downloadchef-zero-c6afab3e124d8e36a690d30617b9b238e96c4741.tar.gz
Don't introduce a "Chef" module, it messes up ChefZero::RSpec's "Chef::Config" detection
-rw-r--r--lib/chef_zero/chef/cookbook/metadata.rb30
-rw-r--r--lib/chef_zero/cookbook_data.rb28
2 files changed, 26 insertions, 32 deletions
diff --git a/lib/chef_zero/chef/cookbook/metadata.rb b/lib/chef_zero/chef/cookbook/metadata.rb
deleted file mode 100644
index bd2bae8..0000000
--- a/lib/chef_zero/chef/cookbook/metadata.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-module ChefZero
- module Chef
- module Cookbook
- # Handles loading configuration values from a Chef config file
- #
- # @author Justin Campbell <justin.campbell@riotgames.com>
- class Metadata < Hash
- # @param [String] path
- def initialize(cookbook)
- self.name(cookbook.name)
- self.recipes(cookbook.fully_qualified_recipe_names)
- end
-
- def from_json(filepath)
- self.merge!(JSON.parse(File.read(filepath)))
- end
-
- private
-
- def method_missing(key, value = nil)
- if value.nil?
- self[key.to_sym]
- else
- store key.to_sym, value
- end
- end
- end
- end
- end
-end
diff --git a/lib/chef_zero/cookbook_data.rb b/lib/chef_zero/cookbook_data.rb
index 6cb0c8c..9aae7f5 100644
--- a/lib/chef_zero/cookbook_data.rb
+++ b/lib/chef_zero/cookbook_data.rb
@@ -1,5 +1,4 @@
require 'digest/md5'
-require 'chef_zero/chef/cookbook/metadata'
module ChefZero
module CookbookData
@@ -29,8 +28,33 @@ module ChefZero
attr_reader :name, :fully_qualified_recipe_names
end
+ # Handles loading configuration values from a Chef config file
+ #
+ # @author Justin Campbell <justin.campbell@riotgames.com>
+ class PretendCookbookMetadata < Hash
+ # @param [String] path
+ def initialize(cookbook)
+ self.name(cookbook.name)
+ self.recipes(cookbook.fully_qualified_recipe_names)
+ end
+
+ def from_json(filepath)
+ self.merge!(JSON.parse(File.read(filepath)))
+ end
+
+ private
+
+ def method_missing(key, value = nil)
+ if value.nil?
+ self[key.to_sym]
+ else
+ store key.to_sym, value
+ end
+ end
+ end
+
def self.metadata_from(directory, name, version, recipe_names)
- metadata = ChefZero::Chef::Cookbook::Metadata.new(PretendCookbook.new(name, 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?