Class: Chef::ChefFS::DataHandler::PolicyDataHandler
- Inherits:
-
DataHandlerBase
- Object
- DataHandlerBase
- Chef::ChefFS::DataHandler::PolicyDataHandler
- Defined in:
- lib/chef/chef_fs/data_handler/policy_data_handler.rb
Instance Method Summary collapse
- #name_and_revision(name) ⇒ Object
- #normalize(policy, entry) ⇒ Object
-
#verify_integrity(object_data, entry) {|s| ... } ⇒ Object
Verify that the JSON hash for this type has a key that matches its name.
Methods inherited from DataHandlerBase
#chef_class, #chef_object, #default, #from_ruby, #minimize, #normalize_for_post, #normalize_for_put, #normalize_hash, #normalize_run_list, #preserve_key?, #remove_file_extension, #to_ruby, #to_ruby_keys
Instance Method Details
#name_and_revision(name) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/chef/chef_fs/data_handler/policy_data_handler.rb', line 7 def name_and_revision(name) # foo-1.0.0 = foo, 1.0.0 name = remove_dot_json(name) if name =~ /^(.*)-([^-]*)$/ name, revision_id = $1, $2 end revision_id ||= "0.0.0" [ name, revision_id ] end |
#normalize(policy, entry) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/chef/chef_fs/data_handler/policy_data_handler.rb', line 17 def normalize(policy, entry) # foo-1.0.0 = foo, 1.0.0 name, revision_id = name_and_revision(entry.name) defaults = { "name" => name, "revision_id" => revision_id, "run_list" => [], "cookbook_locks" => {}, } normalize_hash(policy, defaults) end |
#verify_integrity(object_data, entry) {|s| ... } ⇒ Object
Verify that the JSON hash for this type has a key that matches its name.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/chef/chef_fs/data_handler/policy_data_handler.rb', line 35 def verify_integrity(object_data, entry) name, revision = name_and_revision(entry.name) if object_data["name"] != name yield("Object name '#{object_data["name"]}' doesn't match entry '#{name}'.") end if object_data["revision_id"] != revision yield("Object revision ID '#{object_data["revision_id"]}' doesn't match entry '#{revision}'.") end end |