Class: Chef::RunList::VersionedRecipeList
- Inherits:
-
Array
- Object
- Array
- Chef::RunList::VersionedRecipeList
- Defined in:
- lib/chef/run_list/versioned_recipe_list.rb
Instance Method Summary collapse
- #add_recipe(name, version = nil) ⇒ Object
-
#initialize ⇒ VersionedRecipeList
constructor
A new instance of VersionedRecipeList.
-
#with_duplicate_names ⇒ Array
Get an array of strings of both fully-qualified and unexpanded recipe names in response to chef/chef#3767 Chef-13 will revert to the behaviour of just including the fully-qualified name.
-
#with_fully_qualified_names_and_version_constraints ⇒ Array
Get an array of strings of the fully-qualified recipe names (with ::default appended) and with the versions in “NAME@VERSION” format.
-
#with_version_constraints ⇒ Object
Return an Array of Hashes, each of the form: {:name => RECIPE_NAME, :version_constraint => Chef::VersionConstraint }.
-
#with_version_constraints_strings ⇒ Object
Return an Array of Strings, each of the form: “NAME@VERSION”.
- #with_versions ⇒ Object
Constructor Details
#initialize ⇒ VersionedRecipeList
Returns a new instance of VersionedRecipeList.
27 28 29 30 |
# File 'lib/chef/run_list/versioned_recipe_list.rb', line 27 def initialize super @versions = Hash.new end |
Instance Method Details
#add_recipe(name, version = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/chef/run_list/versioned_recipe_list.rb', line 32 def add_recipe(name, version = nil) if version && @versions.has_key?(name) unless Chef::Version.new(@versions[name]) == Chef::Version.new(version) raise Chef::Exceptions::CookbookVersionConflict, "Run list requires #{name} at versions #{@versions[name]} and #{version}" end end @versions[name] = version if version self << name unless self.include?(name) end |
#with_duplicate_names ⇒ Array
Get an array of strings of both fully-qualified and unexpanded recipe names in response to chef/chef#3767 Chef-13 will revert to the behaviour of just including the fully-qualified name
91 92 93 94 95 96 97 98 99 |
# File 'lib/chef/run_list/versioned_recipe_list.rb', line 91 def with_duplicate_names self.map do |recipe_name| if recipe_name.include?("::") recipe_name else [recipe_name, "#{recipe_name}::default"] end end.flatten end |
#with_fully_qualified_names_and_version_constraints ⇒ Array
Get an array of strings of the fully-qualified recipe names (with ::default appended) and with the versions in “NAME@VERSION” format.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/chef/run_list/versioned_recipe_list.rb', line 71 def with_fully_qualified_names_and_version_constraints self.map do |recipe_name| qualified_recipe = if recipe_name.include?("::") recipe_name else "#{recipe_name}::default" end version = @versions[recipe_name] qualified_recipe = "#{qualified_recipe}@#{version}" if version qualified_recipe end end |
#with_version_constraints ⇒ Object
Return an Array of Hashes, each of the form:
{:name => RECIPE_NAME, :version_constraint => Chef::VersionConstraint }
48 49 50 51 52 53 |
# File 'lib/chef/run_list/versioned_recipe_list.rb', line 48 def with_version_constraints self.map do |recipe_name| constraint = Chef::VersionConstraint.new(@versions[recipe_name]) { :name => recipe_name, :version_constraint => constraint } end end |
#with_version_constraints_strings ⇒ Object
Return an Array of Strings, each of the form:
"NAME@VERSION"
57 58 59 60 61 62 63 64 65 |
# File 'lib/chef/run_list/versioned_recipe_list.rb', line 57 def with_version_constraints_strings self.map do |recipe_name| if @versions[recipe_name] "#{recipe_name}@#{@versions[recipe_name]}" else recipe_name end end end |
#with_versions ⇒ Object
42 43 44 |
# File 'lib/chef/run_list/versioned_recipe_list.rb', line 42 def with_versions self.map { |recipe_name| { :name => recipe_name, :version => @versions[recipe_name] } } end |