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

## Chef::Cookbook::Metadata

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

### Methods

== attribute conflicts depends description from_hash from_hash from_json from_json grouping license long_description maintainer maintainer_email name new provides recipe recommends replaces suggests supports to_hash to_json validate_json version

### Included Modules

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

### Constants

NAME | = | 'name'.freeze
DESCRIPTION | = | 'description'.freeze
LONG_DESCRIPTION | = | 'long_description'.freeze
MAINTAINER | = | 'maintainer'.freeze
MAINTAINER_EMAIL | = | 'maintainer_email'.freeze
LICENSE | = | 'license'.freeze
PLATFORMS | = | 'platforms'.freeze
DEPENDENCIES | = | 'dependencies'.freeze
RECOMMENDATIONS | = | 'recommendations'.freeze
SUGGESTIONS | = | 'suggestions'.freeze
CONFLICTING | = | 'conflicting'.freeze
PROVIDING | = | 'providing'.freeze
REPLACING | = | 'replacing'.freeze
ATTRIBUTES | = | 'attributes'.freeze
GROUPINGS | = | 'groupings'.freeze
RECIPES | = | 'recipes'.freeze
VERSION | = | 'version'.freeze
COMPARISON_FIELDS | = | [ :name, :description, :long_description, :maintainer, :maintainer_email, :license, :platforms, :dependencies, :recommendations, :suggestions, :conflicting, :providing, :replacing, :attributes, :groupings, :recipes, :version]
VERSION_CONSTRAINTS | = | {:depends => DEPENDENCIES, :recommends => RECOMMENDATIONS, :suggests => SUGGESTIONS, :conflicts => CONFLICTING, :provides => PROVIDING, :replaces => REPLACING }

### 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

from_hash(o)
from_json(string)
new(cookbook=nil, maintainer='Your Name', maintainer_email='youremail@example.com', license='Apache v2.0')

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>

validate_json(json_str)

### Public Instance methods

==(other)
attribute(name, options)

Adds an attribute )hat 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

conflicts(cookbook, *version_args)

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

### Parameters

cookbook<String>: | The cookbook
version<String>: | A version constraint of the form "OP VERSION",

where OP is one of < <= = > >= ~> and VERSION has the form x.y.z or x.y.

### Returns

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

depends(cookbook, *version_args)

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

### Parameters

cookbook<String>: | The cookbook
version<String>: | A version constraint of the form "OP VERSION",

where OP is one of < <= = > >= ~> and VERSION has the form x.y.z or x.y.

### Returns

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

description(arg=nil)

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

from_hash(o)
from_json(string)
grouping(name, options)
license(arg=nil)

Sets the current license, or returns it.

### Parameters

license<String>: | The current license.

### Returns

license<String>: | Returns the current license

long_description(arg=nil)

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

maintainer(arg=nil)

Sets the cookbooks maintainer, or returns it.

### Parameters

maintainer<String>: | The maintainers name

### Returns

maintainer<String>: | Returns the current maintainer.

maintainer_email(arg=nil)

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.

name(arg=nil)

Sets the name of the cookbook, or returns it.

### Parameters

name<String>: | The curent cookbook name.

### Returns

name<String>: | Returns the current cookbook name.

provides(cookbook, *version_args)

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
version<String>: | A version constraint of the form "OP VERSION",

where OP is one of < <= = > >= ~> and VERSION has the form x.y.z or x.y.

### Returns

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

recipe(name, description)

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

recommends(cookbook, *version_args)

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

### Parameters

cookbook<String>: | The cookbook
version<String>: | A version constraint of the form "OP VERSION",

where OP is one of < <= = > >= ~> and VERSION has the form x.y.z or x.y.

### Returns

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

replaces(cookbook, *version_args)

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

### Parameters

cookbook<String>: | The cookbook we replace
version<String>: | A version constraint of the form "OP VERSION",

where OP is one of < <= = > >= ~> and VERSION has the form x.y.z or x.y.

### Returns

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

suggests(cookbook, *version_args)

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

### Parameters

cookbook<String>: | The cookbook
version<String>: | A version constraint of the form "OP VERSION",

where OP is one of < <= = > >= ~> and VERSION has the formx.y.z or x.y.

### Returns

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

supports(platform, *version_args)

Adds a supported platform, with version checking strings.

### Parameters

platform<String>,<Symbol>: | The platform (like :ubuntu or :mac_os_x)
version<String>: | A version constraint of the form "OP VERSION",

where OP is one of < <= = > >= ~> and VERSION has the form x.y.z or x.y.

### Returns

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

to_hash()
to_json(*a)
version(arg=nil)

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]