class Berkshelf::API::CacheBuilder::Worker::Supermarket

Attributes

connection[RW]

Public Class Methods

new(options = {}) click to toggle source

@param [Hash] options

see {API::SiteConnector::Supermarket.new} for options
# File lib/berkshelf/api/cache_builder/worker/supermarket.rb, line 9
def initialize(options = {})
  @connection = Berkshelf::API::SiteConnector::Supermarket.new(options)
  super
end

Public Instance Methods

cookbooks() click to toggle source

@return [Array<RemoteCookbook>]

The list of cookbooks this builder can find
# File lib/berkshelf/api/cache_builder/worker/supermarket.rb, line 16
def cookbooks
  connection.universe.inject([]) do |list, (name, versions)|
    versions.each do |version, info|
      list << RemoteCookbook.new(name, version, self.class.worker_type, info["location_path"], priority, info)
    end

    list
  end
end
metadata(remote) click to toggle source

Return the metadata of the given RemoteCookbook. If the metadata could not be found or parsed nil is returned.

@param [RemoteCookbook] remote

@return [Ridley::Chef::Cookbook::Metadata, nil]

# File lib/berkshelf/api/cache_builder/worker/supermarket.rb, line 32
def metadata(remote)
  Ridley::Chef::Cookbook::Metadata.from_hash(
    'name'         => remote.name,
    'version'      => remote.version,
    'dependencies' => remote.info['dependencies'] || {},
  )
end