Sha256: e1e3876d43447fef9009a45d65229992b02414c66ce3129d20d88ce930fa0a75

Contents?: true

Size: 974 Bytes

Versions: 9

Compression:

Stored size: 974 Bytes

Contents

require 'chef_fs/data_handler/data_handler_base'
require 'chef/cookbook/metadata'

module ChefFS
  module DataHandler
    class CookbookDataHandler < DataHandlerBase
      def normalize(cookbook, entry)
        version = entry.name
        name = entry.parent.name
        result = normalize_hash(cookbook, {
          'name' => "#{name}-#{version}",
          'version' => version,
          'cookbook_name' => name,
          'json_class' => 'Chef::CookbookVersion',
          'chef_type' => 'cookbook_version',
          'frozen?' => false,
          'metadata' => {}
        })
        result['metadata'] = normalize_hash(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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
knife-essentials-1.5.6 lib/chef_fs/data_handler/cookbook_data_handler.rb
knife-essentials-1.5.5 lib/chef_fs/data_handler/cookbook_data_handler.rb
knife-essentials-1.5.4 lib/chef_fs/data_handler/cookbook_data_handler.rb
knife-essentials-1.5.3 lib/chef_fs/data_handler/cookbook_data_handler.rb
knife-essentials-1.5.2 lib/chef_fs/data_handler/cookbook_data_handler.rb
knife-essentials-1.5.1 lib/chef_fs/data_handler/cookbook_data_handler.rb
knife-essentials-1.5 lib/chef_fs/data_handler/cookbook_data_handler.rb
knife-essentials-1.4 lib/chef_fs/data_handler/cookbook_data_handler.rb
knife-essentials-1.3.2 lib/chef_fs/data_handler/cookbook_data_handler.rb