Method: Berkshelf::CachedCookbook.from_store_path

Defined in:
lib/berkshelf/cached_cookbook.rb

.from_store_path(path) ⇒ CachedCookbook

Returns an instance of CachedCookbook initialized by the contents found at the given path.

Parameters:

  • path (#to_s)

    a path on disk to the location of a Cookbook downloaded by the Downloader

Returns:

  • (CachedCookbook)

    an instance of CachedCookbook initialized by the contents found at the given path.



15
16
17
18
19
20
21
# File 'lib/berkshelf/cached_cookbook.rb', line 15

def from_store_path(path)
  path        = Pathname.new(path)
  cached_name = File.basename(path.to_s).slice(DIRNAME_REGEXP, 1)
  return nil if cached_name.nil?

  loaded_cookbooks[path.to_s] ||= from_path(path)
end