Class: Berkshelf::API::CacheBuilder::Worker::Supermarket

Inherits:
Base
  • Object
show all
Defined in:
lib/berkshelf/api/cache_builder/worker/supermarket.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #priority

Instance Method Summary collapse

Methods inherited from Base

#to_s, worker_type

Methods included from Mixin::Services

extended, included

Methods included from Logging

init, #logger

Constructor Details

#initialize(options = {}) ⇒ Supermarket

Returns a new instance of Supermarket.

Parameters:

  • options (Hash) (defaults to: {})

    see API::SiteConnector::Supermarket.new for options



9
10
11
12
# File 'lib/berkshelf/api/cache_builder/worker/supermarket.rb', line 9

def initialize(options = {})
  @connection = Berkshelf::API::SiteConnector::Supermarket.new(options)
  super
end

Instance Method Details

#cookbooksArray<RemoteCookbook>

Returns The list of cookbooks this builder can find.

Returns:

  • (Array<RemoteCookbook>)

    The list of cookbooks this builder can find



16
17
18
19
20
21
22
23
24
# 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) ⇒ Ridley::Chef::Cookbook::Metadata?

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

Parameters:

Returns:

  • (Ridley::Chef::Cookbook::Metadata, nil)


32
33
34
35
36
37
38
# File 'lib/berkshelf/api/cache_builder/worker/supermarket.rb', line 32

def (remote)
  Ridley::Chef::Cookbook::Metadata.from_hash(
    'name'         => remote.name,
    'version'      => remote.version,
    'dependencies' => remote.info['dependencies'] || {},
  )
end