summaryrefslogtreecommitdiff
path: root/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/chef_fs/data_handler/cookbook_data_handler.rb')
-rw-r--r--lib/chef/chef_fs/data_handler/cookbook_data_handler.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb b/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb
new file mode 100644
index 0000000000..d0333db48f
--- /dev/null
+++ b/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb
@@ -0,0 +1,38 @@
+require 'chef/chef_fs/data_handler/data_handler_base'
+require 'chef/cookbook/metadata'
+
+class Chef
+ module ChefFS
+ module DataHandler
+ class CookbookDataHandler < DataHandlerBase
+ def normalize(cookbook, entry)
+ version = entry.name
+ name = entry.parent.name
+ result = super(cookbook, {
+ 'name' => "#{name}-#{version}",
+ 'version' => version,
+ 'cookbook_name' => name,
+ 'json_class' => 'Chef::CookbookVersion',
+ 'chef_type' => 'cookbook_version',
+ 'frozen?' => false,
+ 'metadata' => {}
+ })
+ result['metadata'] = super(result['metadata'], {
+ 'version' => version,
+ 'name' => name
+ })
+ end
+
+ def preserve_key(key)
+ return key == 'cookbook_name' || key == 'version'
+ end
+
+ def chef_class
+ Chef::Cookbook::Metadata
+ end
+
+ # Not using this yet, so not sure if to_ruby will be useful.
+ end
+ end
+ end
+end