Class: Chef::Cookbook::FileVendor

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/cookbook/file_vendor.rb

Overview

== Chef::Cookbook::FileVendor This class handles fetching of cookbook files based on specificity.

Direct Known Subclasses

FileSystemFileVendor, RemoteFileVendor

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_from_manifest(manifest) ⇒ Object

Factory method that creates the appropriate kind of Cookbook::FileVendor to serve the contents of the manifest


54
55
56
57
58
59
# File 'lib/chef/cookbook/file_vendor.rb', line 54

def self.create_from_manifest(manifest)
  if @vendor_class.nil?
    raise "Must configure FileVendor to use a specific implementation before creating an instance"
  end
  @vendor_class.new(manifest, @initialization_options)
end

.fetch_from_disk(cookbook_paths) ⇒ Object


37
38
39
40
# File 'lib/chef/cookbook/file_vendor.rb', line 37

def self.fetch_from_disk(cookbook_paths)
  @vendor_class = FileSystemFileVendor
  @initialization_options = cookbook_paths
end

.fetch_from_remote(http_client) ⇒ Object

Configures FileVendor to use the RemoteFileVendor implementation. After calling this, subsequent calls to create_from_manifest will return a RemoteFileVendor object initialized with the given http_client


32
33
34
35
# File 'lib/chef/cookbook/file_vendor.rb', line 32

def self.fetch_from_remote(http_client)
  @vendor_class = RemoteFileVendor
  @initialization_options = http_client
end

.initialization_optionsObject


48
49
50
# File 'lib/chef/cookbook/file_vendor.rb', line 48

def self.initialization_options
  @initialization_options
end

.vendor_classObject

Returns the implementation class that is currently configured, or nil if one has not been configured yet.


44
45
46
# File 'lib/chef/cookbook/file_vendor.rb', line 44

def self.vendor_class
  @vendor_class
end

Instance Method Details

#get_filename(filename) ⇒ Object

Gets the on-disk location for the given cookbook file.

Subclasses are responsible for determining exactly how the files are obtained and where they are stored.

Raises:

  • (NotImplemented)

65
66
67
# File 'lib/chef/cookbook/file_vendor.rb', line 65

def get_filename(filename)
  raise NotImplemented, "Subclasses must implement this method"
end