Method: Ridley::Chef::Cookbook.from_path
- Defined in:
- lib/ridley/chef/cookbook.rb
.from_path(path) ⇒ 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.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ridley/chef/cookbook.rb', line 32 def from_path(path) path = Pathname.new(path) if (file = path.join(Metadata::COMPILED_FILE_NAME)).exist? = Metadata.from_json(File.read(file)) elsif (file = path.join(Metadata::RAW_FILE_NAME)).exist? = Metadata.from_file(file) else raise IOError, "no #{Metadata::COMPILED_FILE_NAME} or #{Metadata::RAW_FILE_NAME} found at #{path}" end unless .name.presence raise Ridley::Errors::MissingNameAttribute.new(path) end new(.name, path, ) end |