lib/ridley/chef/cookbook.rb
# Creates a new instance of Ridley::Chef::Cookbook from a path on disk containing
# a Cookbook.
#
# The name of the Cookbook is determined by the value of the name attribute set in
# the cookbooks' metadata. If the name attribute is not present the name of the loaded
# cookbook is determined by directory containing the cookbook.
#
# @param [#to_s] path
#   a path on disk to the location of a Cookbook
#
# @option options [String] :name
#   explicitly supply the name of the cookbook we are loading. This is useful if
#   you are dealing with a cookbook that does not have well-formed metadata
#
# @raise [IOError] if the path does not contain a metadata.rb or metadata.json file
#
# @return [Ridley::Chef::Cookbook]
Creates a new instance of Ridley::Chef::Cookbook from a path on disk containing
a Cookbook.

The name of the Cookbook is determined by the value of the name attribute set in
the cookbooks' metadata. If the name attribute is not present the name of the loaded
cookbook is determined by directory containing the cookbook.
Creates a new instance of Ridley :: Chef :: Cookbook from a path on disk containing a Cookbook . The name of the Cookbook is determined by the value of the name attribute set in the cookbooks ' metadata . If the name attribute is not present the name of the loaded cookbook is determined by directory containing the cookbook .
def from_path(path, options = {})
        path     = Pathname.new(path)
        metadata = if path.join('metadata.rb').exist?
          Cookbook::Metadata.from_file(path.join('metadata.rb'))
        elsif path.join('metadata.json').exist?
          Cookbook::Metadata.from_json(File.read(path.join('metadata.json')))
        else
          raise IOError, "no metadata.rb or metadata.json found at #{path}"
        end
        metadata.name(options[:name].presence || metadata.name.presence || File.basename(path))
        new(metadata.name, path, metadata)
      end
def from_path ( path , options = { } ) path = Pathname . new ( path ) metadata = if path . join ( 'metadata.rb' ) . exist? Cookbook :: Metadata . from_file ( path . join ( 'metadata.rb' ) ) elsif path . join ( 'metadata.json' ) . exist? Cookbook :: Metadata . from_json ( File . read ( path . join ( 'metadata.json' ) ) ) else raise IOError , "no metadata.rb or metadata.json found at #{path}" end metadata . name ( options [ :name ] . presence || metadata . name . presence || File . basename ( path ) ) new ( metadata . name , path , metadata ) end
Creates a new instance of Ridley::Chef::Cookbook from a path on disk containing
a Cookbook.
Creates a new instance of Ridley :: Chef :: Cookbook from a path on disk containing a Cookbook .
None
Ridley::Chef::Cookbook
[IOError] if the path does not contain a metadata.rb or metadata.json file
[ IOError ] if the path does not contain a metadata . rb or metadata . json file
path
<not_specific>
options
:name explicitly supply the name of the cookbook we are loading. This is useful if you are dealing with a cookbook that does not have well-formed metadata
: name explicitly supply the name of the cookbook we are loading . This is useful if you are dealing with a cookbook that does not have well - formed metadata
<not_specific>
path a path on disk to the location of a Cookbook
path a path on disk to the location of a Cookbook