Class: Chef::ChefFS::DataHandler::CookbookDataHandler

Inherits:
DataHandlerBase show all
Defined in:
lib/chef/chef_fs/data_handler/cookbook_data_handler.rb

Instance Method Summary collapse

Methods inherited from DataHandlerBase

#chef_object, #default, #from_ruby, #minimize, #normalize_for_post, #normalize_for_put, #normalize_hash, #normalize_run_list, #remove_file_extension, #to_ruby, #to_ruby_keys, #verify_integrity

Instance Method Details

#chef_classObject



30
31
32
# File 'lib/chef/chef_fs/data_handler/cookbook_data_handler.rb', line 30

def chef_class
  Chef::Cookbook::Metadata
end

#normalize(cookbook, entry) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/chef/chef_fs/data_handler/cookbook_data_handler.rb', line 8

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

#preserve_key?(key) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/chef/chef_fs/data_handler/cookbook_data_handler.rb', line 26

def preserve_key?(key)
  %w{cookbook_name version}.include?(key)
end