Class: Berkshelf::API::CacheBuilder::Worker::FileStore

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

Instance Attribute Summary collapse

Attributes inherited from Base

#options, #priority

Instance Method Summary collapse

Methods inherited from Base

worker_type

Methods included from Mixin::Services

extended, included

Methods included from Logging

init, #logger

Constructor Details

#initialize(options = {}) ⇒ FileStore

Returns a new instance of FileStore.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :path (String)

    the directory to search for local cookbooks



12
13
14
15
# File 'lib/berkshelf/api/cache_builder/worker/file_store.rb', line 12

def initialize(options = {})
  @path = Pathname(options[:path])
  super(options)
end

Instance Attribute Details

#pathString (readonly)

Returns:

  • (String)


8
9
10
# File 'lib/berkshelf/api/cache_builder/worker/file_store.rb', line 8

def path
  @path
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



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/berkshelf/api/cache_builder/worker/file_store.rb', line 24

def cookbooks
  [].tap do |cookbook_versions|
    @path.each_child do |dir|
      next unless dir.cookbook?
      begin
        cookbook = Ridley::Chef::Cookbook.from_path(dir)
        cookbook_versions << RemoteCookbook.new(cookbook.cookbook_name, cookbook.version,
          self.class.worker_type, cookbook.path, priority)
      rescue => ex
        log.debug ex.message
      end
    end
  end
end

#metadata(remote) ⇒ Ridley::Chef::Cookbook::Metadata

Parameters:

Returns:

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


42
43
44
# File 'lib/berkshelf/api/cache_builder/worker/file_store.rb', line 42

def (remote)
  (remote.location_path)
end

#to_sString

Returns:

  • (String)


18
19
20
# File 'lib/berkshelf/api/cache_builder/worker/file_store.rb', line 18

def to_s
  friendly_name(path)
end