Class Chef::Cookbook::Metadata
In: lib/chef/cookbook/metadata/version.rb
lib/chef/cookbook/metadata.rb
Parent: Object

Chef::Cookbook::Metadata

Chef::Cookbook::Metadata provides a convenient DSL for declaring metadata about Chef Cookbooks.

Methods

Included Modules

Chef::Mixin::CheckHelper Chef::Mixin::ParamsValidate Chef::Mixin::FromFile

Classes and Modules

Class Chef::Cookbook::Metadata::Version

Constants

COMPARISON_FIELDS = [ :name, :description, :long_description, :maintainer, :maintainer_email, :license, :platforms, :dependencies, :recommendations, :suggestions, :conflicting, :providing, :replacing, :attributes, :groupings, :recipes, :version]

Attributes

attributes  [R] 
conflicting  [R] 
cookbook  [R] 
dependencies  [R] 
groupings  [R] 
platforms  [R] 
providing  [R] 
recipes  [R] 
recommendations  [R] 
replacing  [R] 
suggestions  [R] 
version  [R] 

Public Class methods

Builds a new Chef::Cookbook::Metadata object.

Parameters

cookbook<String>:An optional cookbook object
maintainer<String>:An optional maintainer
maintainer_email<String>:An optional maintainer email

license<String>::An optional license. Default is Apache v2.0

Returns

metadata<Chef::Cookbook::Metadata>

Public Instance methods

Adds an attribute that a user needs to configure for this cookbook. Takes a name (with the / notation for a nested attribute), followed by any of these options

  display_name<String>:: What a UI should show for this attribute
  description<String>:: A hint as to what this attr is for
  choice<Array>:: An array of choices to present to the user.
  calculated<Boolean>:: If true, the default value is calculated by the recipe and cannot be displayed.
  type<String>:: "string" or "array" - default is "string"  ("hash" is supported for backwards compatibility)
  required<String>:: Whether this attr is 'required', 'recommended' or 'optional' - default 'optional' (true/false values also supported for backwards compatibility)
  recipes<Array>:: An array of recipes which need this attr set.
  default<String>,<Array>,<Hash>:: The default value

Parameters

name<String>:The name of the attribute (‘foo’, or ‘apache2/log_dir’)
options<Hash>:The description of the options

Returns

options<Hash>:Returns the current options hash

Adds a conflict for another cookbook, with version checking strings.

Parameters

cookbook<String>:The cookbook
*versions<String>:A list of versions matching << <= = >= >> followed by a version.

Returns

versions<Array>:Returns the list of versions for the platform

Adds a dependency on another cookbook, with version checking strings.

Parameters

cookbook<String>:The cookbook
*versions<String>:A list of versions matching << <= = >= >> followed by a version.

Returns

versions<Array>:Returns the list of versions for the platform

Sets the current description, or returns it. Should be short - one line only!

Parameters

description<String>:The new description

Returns

description<String>:Returns the description

Sets the current license, or returns it.

Parameters

license<String>:The current license.

Returns

license<String>:Returns the current license

Sets the current long description, or returns it. Might come from a README, say.

Parameters

long_description<String>:The new long description

Returns

long_description<String>:Returns the long description

Sets the cookbooks maintainer, or returns it.

Parameters

maintainer<String>:The maintainers name

Returns

maintainer<String>:Returns the current maintainer.

Sets the maintainers email address, or returns it.

Parameters

maintainer_email<String>:The maintainers email address

Returns

maintainer_email<String>:Returns the current maintainer email.

Sets the name of the cookbook, or returns it.

Parameters

name<String>:The curent cookbook name.

Returns

name<String>:Returns the current cookbook name.

Adds a recipe, definition, or resource provided by this cookbook.

Recipes are specified as normal Definitions are followed by (), and can include :params for prototyping Resources are the stringified version (service[apache2])

Parameters

recipe, definition, resource<String>:The thing we provide
*versions<String>:A list of versions matching << <= = >= >> followed by a version.

Returns

versions<Array>:Returns the list of versions for the platform

Adds a description for a recipe.

Parameters

recipe<String>:The recipe
description<String>:The description of the recipe

Returns

description<String>:Returns the current description

Adds a recommendation for another cookbook, with version checking strings.

Parameters

cookbook<String>:The cookbook
*versions<String>:A list of versions matching << <= = >= >> followed by a version.

Returns

versions<Array>:Returns the list of versions for the platform

Adds a cookbook that is replaced by this one, with version checking strings.

Parameters

cookbook<String>:The cookbook we replace
*versions<String>:A list of versions matching << <= = >= >> followed by a version.

Returns

versions<Array>:Returns the list of versions for the platform

Adds a suggestion for another cookbook, with version checking strings.

Parameters

cookbook<String>:The cookbook
*versions<String>:A list of versions matching << <= = >= >> followed by a version.

Returns

versions<Array>:Returns the list of versions for the platform

Adds a supported platform, with version checking strings.

Parameters

platform<String>,<Symbol>:The platform (like :ubuntu or :mac_os_x)
*versions<String>:A list of versions matching << <= = >= >> followed by a version.

Returns

versions<Array>:Returns the list of versions for the platform

Sets the current cookbook version, or returns it. Can be two or three digits, seperated by dots. ie: ‘2.1’, ‘1.5.4’ or ‘0.9’.

Parameters

version<String>:The curent version, as a string

Returns

version<String>:Returns the current version

[Validate]