Class: Chef::Cookbook::FileVendor
- Inherits:
-
Object
- Object
- Chef::Cookbook::FileVendor
- 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
Class Method Summary collapse
-
.create_from_manifest(manifest) ⇒ Object
Factory method that creates the appropriate kind of Cookbook::FileVendor to serve the contents of the manifest.
- .fetch_from_disk(cookbook_paths) ⇒ Object
-
.fetch_from_remote(http_client) ⇒ Object
Configures FileVendor to use the RemoteFileVendor implementation.
- .initialization_options ⇒ Object
-
.vendor_class ⇒ Object
Returns the implementation class that is currently configured, or ‘nil` if one has not been configured yet.
Instance Method Summary collapse
-
#get_filename(filename) ⇒ Object
Gets the on-disk location for the given cookbook file.
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_options ⇒ Object
47 48 49 |
# File 'lib/chef/cookbook/file_vendor.rb', line 47 def self. @initialization_options end |
.vendor_class ⇒ Object
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.
65 66 67 |
# File 'lib/chef/cookbook/file_vendor.rb', line 65 def get_filename(filename) raise NotImplemented, "Subclasses must implement this method" end |