summaryrefslogtreecommitdiff
path: root/lib/chef/cookbook_version.rb
diff options
context:
space:
mode:
authorNikhil Benesch <nikhil.benesch@gmail.com>2014-05-04 02:56:07 -0400
committerClaire McQuin <claire@getchef.com>2014-05-13 15:21:16 -0700
commitd465f8ca9937e871caa409988f5909b2b0f0f843 (patch)
treefdbe3d24c05ddec47fa8802ab7d032b00df34687 /lib/chef/cookbook_version.rb
parent89d5d20dcd494c7d42a1f24f8a3ab7712735267e (diff)
downloadchef-d465f8ca9937e871caa409988f5909b2b0f0f843.tar.gz
CHEF-4423: extract CookbookVersion manifest update into public method
Certain segments of a CookbookVersion's manifest (recipe, attributes) have custom setter methods. Extract the logic to handle these special cases into a public method to reduce duplication.
Diffstat (limited to 'lib/chef/cookbook_version.rb')
-rw-r--r--lib/chef/cookbook_version.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 27dc8ef9e5..cbae3a552d 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -169,14 +169,7 @@ class Chef
next unless @manifest.has_key?(segment)
filenames = @manifest[segment].map{|manifest_record| manifest_record['name']}
- if segment == :recipes
- self.recipe_filenames = filenames
- elsif segment == :attributes
- self.attribute_filenames = filenames
- else
- segment_filenames(segment).clear
- filenames.each { |filename| segment_filenames(segment) << filename }
- end
+ replace_segment_filenames(segment, filenames)
end
end
@@ -272,6 +265,17 @@ class Chef
end
end
+ def replace_segment_filenames(segment, filenames)
+ case segment.to_sym
+ when :recipes
+ self.recipe_filenames = filenames
+ when :attributes
+ self.attribute_filenames = filenames
+ else
+ segment_filenames(segment).replace(filenames)
+ end
+ end
+
# Query whether a template file +template_filename+ is available. File
# specificity for the given +node+ is obeyed in the lookup.
def has_template_for_node?(node, template_filename)