Class: ChefCLI::Policyfile::RevIDLockDataMap
- Inherits:
-
Object
- Object
- ChefCLI::Policyfile::RevIDLockDataMap
- Defined in:
- lib/chef-cli/policyfile/lister.rb
Instance Attribute Summary collapse
-
#lock_info_by_rev_id ⇒ Object
readonly
Returns the value of attribute lock_info_by_rev_id.
-
#policy_name ⇒ Object
readonly
Returns the value of attribute policy_name.
Instance Method Summary collapse
- #all_cookbook_names ⇒ Object
- #cb_info_for(rev_id, cookbook_name) ⇒ Object
- #cbs_with_differing_ids ⇒ Object
-
#initialize(policy_name, lock_info_by_rev_id) ⇒ RevIDLockDataMap
constructor
A new instance of RevIDLockDataMap.
Constructor Details
#initialize(policy_name, lock_info_by_rev_id) ⇒ RevIDLockDataMap
Returns a new instance of RevIDLockDataMap.
31 32 33 34 |
# File 'lib/chef-cli/policyfile/lister.rb', line 31 def initialize(policy_name, lock_info_by_rev_id) @policy_name = policy_name @lock_info_by_rev_id = lock_info_by_rev_id end |
Instance Attribute Details
#lock_info_by_rev_id ⇒ Object (readonly)
Returns the value of attribute lock_info_by_rev_id.
29 30 31 |
# File 'lib/chef-cli/policyfile/lister.rb', line 29 def lock_info_by_rev_id @lock_info_by_rev_id end |
#policy_name ⇒ Object (readonly)
Returns the value of attribute policy_name.
28 29 30 |
# File 'lib/chef-cli/policyfile/lister.rb', line 28 def policy_name @policy_name end |
Instance Method Details
#all_cookbook_names ⇒ Object
60 61 62 63 64 |
# File 'lib/chef-cli/policyfile/lister.rb', line 60 def all_cookbook_names lock_info_by_rev_id.inject(Set.new) do |cb_set, (_rev_id, rev_info)| cb_set.merge(rev_info["cookbook_locks"].keys) end end |
#cb_info_for(rev_id, cookbook_name) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/chef-cli/policyfile/lister.rb', line 36 def cb_info_for(rev_id, cookbook_name) lock = lock_info_by_rev_id[rev_id] cookbook_lock = lock["cookbook_locks"][cookbook_name] if cookbook_lock [cookbook_lock["version"], cookbook_lock["identifier"] ] else nil end end |
#cbs_with_differing_ids ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/chef-cli/policyfile/lister.rb', line 47 def cbs_with_differing_ids cbs_with_differing_ids = Set.new all_cookbook_names.each do |cookbook_name| all_identifiers = lock_info_by_rev_id.inject(Set.new) do |id_set, (_rev_id, rev_info)| cookbook_lock = rev_info["cookbook_locks"][cookbook_name] identifier = cookbook_lock && cookbook_lock["identifier"] id_set << identifier end cbs_with_differing_ids << cookbook_name if all_identifiers.size > 1 end cbs_with_differing_ids end |