class Minimart::Mirror::SourceCookbook
A wrapper around a cookbook as found in the universe.json file from an external source (Chef Supermarket, etc…).
Attributes
@return [Hash<String,String>] any dependencies the cookbook has
@return [String] URL to download the cookbook
@return [String] the path to the cookbook
@return [String] the type of location the cookbook is stored in (supermarket, etc.)
@return [String] the name of the cookbook
@return [String] the version of the cookbook
Public Class Methods
@param [Hash] opts @option opts [String] name The name of the cookbook @option opts [String] version The version of the cookbook @option opts [String] location_path
The path to the cookbook @option opts [String] download_url
URL to download the cookbook @option opts [Hash] dependencies A hash containing any of the cookbook's dependencies. @option opts [String] location_type
The type of location the cookbook is stored in (supermarket, etc.)
# File lib/minimart/mirror/source_cookbook.rb, line 35 def initialize(opts) @name = fetch_from_options(opts, 'name') @version = fetch_from_options(opts, 'version') @location_path = fetch_from_options(opts, 'location_path') @download_url = fetch_from_options(opts, 'download_url') @dependencies = fetch_from_options(opts, 'dependencies') || {} @location_type = fetch_from_options(opts, 'location_type') end
Public Instance Methods
Download
this remote cookbook @yield [Dir] The path to the downloaded cookbook. This directory will be removed when the block exits.
# File lib/minimart/mirror/source_cookbook.rb, line 46 def fetch(&block) Download::Cookbook.new(self).fetch(&block) end
Get the location_path
as a URI @return [URI]
# File lib/minimart/mirror/source_cookbook.rb, line 64 def location_path_uri URI.parse(location_path) end
Convert this remote cookbook to a Hash @return [Hash]
# File lib/minimart/mirror/source_cookbook.rb, line 52 def to_hash { metadata_version: '2.0', name: @name, version: @version, source_type: location_type, location: location_path } end
# File lib/minimart/mirror/source_cookbook.rb, line 68 def web_friendly_version version.gsub('.', '_') end
Private Instance Methods
# File lib/minimart/mirror/source_cookbook.rb, line 74 def fetch_from_options(opts, key) opts[key] || opts[key.to_sym] end