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



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

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



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

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



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

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

.initialization_optionsObject



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

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.



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

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