class Berkshelf::API::CacheBuilder::Worker::FileStore
Attributes
path[R]
@return [String]
Public Class Methods
new(options = {})
click to toggle source
@option options [String] :path
the directory to search for local cookbooks
Calls superclass method
Berkshelf::API::CacheBuilder::Worker::Base::new
# File lib/berkshelf/api/cache_builder/worker/file_store.rb, line 14 def initialize(options = {}) @path = Pathname(options[:path]) log.warn "You have configured a FileStore endpoint to index the contents of #{@path}." log.warn "Using unfinalized artifacts, which this path may contain, to satisfiy your" log.warn "dependencies is *STRONGLY FROWNED UPON* and potentially *DANGEROUS*." log.warn "" log.warn "Please consider setting up a release process for the cookbooks you wish to retrieve from this" log.warn "filepath where the cookbook is uploaded into a Hosted Chef organization, an internal" log.warn "Chef Server, or the community site, and then replace this endpoint with a chef_server endpoint." super(options) 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/file_store.rb, line 33 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)
click to toggle source
@param [RemoteCookbook] remote
@return [Ridley::Chef::Cookbook::Metadata]
# File lib/berkshelf/api/cache_builder/worker/file_store.rb, line 51 def metadata(remote) load_metadata(remote.location_path) end
to_s()
click to toggle source
@return [String]
# File lib/berkshelf/api/cache_builder/worker/file_store.rb, line 27 def to_s friendly_name(path) end
Private Instance Methods
load_metadata(path)
click to toggle source
Helper function for loading metadata from a particular directory
@param [String] path
path of directory to load from
@return [Ridley::Chef::Cookbook::Metadata, nil]
# File lib/berkshelf/api/cache_builder/worker/file_store.rb, line 63 def load_metadata(path) cookbook = Ridley::Chef::Cookbook.from_path(path) cookbook.metadata rescue => ex nil end