Class: ChefCLI::Policyfile::StorageConfig
- Inherits:
-
Object
- Object
- ChefCLI::Policyfile::StorageConfig
- Defined in:
- lib/chef-cli/policyfile/storage_config.rb
Overview
Provides handling of relative paths, such as on disk cookbooks which are specified relative to the Policyfile and local caching of compiled Policyfile artifacts.
Instance Attribute Summary collapse
- #cache_path ⇒ Object
-
#policyfile_filename ⇒ String
readonly
Uncompiled Policyfile filename.
-
#policyfile_lock_filename ⇒ String
readonly
Filename of compiled Policyfile.
- #relative_paths_root ⇒ Object
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ StorageConfig
constructor
A new instance of StorageConfig.
- #policyfile_expanded_path ⇒ Object
- #policyfile_lock_expanded_path ⇒ Object
- #use_policyfile(policyfile_filename) ⇒ Object
- #use_policyfile_lock(policyfile_lock_filename) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ StorageConfig
Returns a new instance of StorageConfig.
42 43 44 45 46 47 48 |
# File 'lib/chef-cli/policyfile/storage_config.rb', line 42 def initialize( = {}) @relative_paths_root = Dir.pwd @cache_path = CookbookOmnifetch.storage_path @policyfile_filename = "<< Policyfile filename not specified >>" @policyfile_lock_filename = "<< Policyfile lock filename not specified >>" () end |
Instance Attribute Details
#cache_path ⇒ Object
37 38 39 |
# File 'lib/chef-cli/policyfile/storage_config.rb', line 37 def cache_path @cache_path end |
#policyfile_filename ⇒ String (readonly)
Uncompiled Policyfile filename.
34 35 36 |
# File 'lib/chef-cli/policyfile/storage_config.rb', line 34 def policyfile_filename @policyfile_filename end |
#policyfile_lock_filename ⇒ String (readonly)
Filename of compiled Policyfile.
34 35 36 |
# File 'lib/chef-cli/policyfile/storage_config.rb', line 34 def policyfile_lock_filename @policyfile_lock_filename end |
#relative_paths_root ⇒ Object
36 37 38 |
# File 'lib/chef-cli/policyfile/storage_config.rb', line 36 def relative_paths_root @relative_paths_root end |
Instance Method Details
#policyfile_expanded_path ⇒ Object
71 72 73 |
# File 'lib/chef-cli/policyfile/storage_config.rb', line 71 def File.(policyfile_filename, relative_paths_root) end |
#policyfile_lock_expanded_path ⇒ Object
75 76 77 |
# File 'lib/chef-cli/policyfile/storage_config.rb', line 75 def File.(policyfile_lock_filename, relative_paths_root) end |
#use_policyfile(policyfile_filename) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/chef-cli/policyfile/storage_config.rb', line 50 def use_policyfile(policyfile_filename) if policyfile_filename.end_with?(".lock.json") return use_policyfile_lock(policyfile_filename) end unless policyfile_filename.end_with?(".rb") raise InvalidPolicyfileFilename, "Policyfile filenames must end with an `.rb' or `.lock.json' extension (you gave: `#{policyfile_filename}')" end @policyfile_filename = policyfile_filename @policyfile_lock_filename = policyfile_filename.sub(/\.rb\Z/, ".lock.json") @relative_paths_root = File.dirname(policyfile_filename) self end |
#use_policyfile_lock(policyfile_lock_filename) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/chef-cli/policyfile/storage_config.rb', line 64 def use_policyfile_lock(policyfile_lock_filename) @policyfile_lock_filename = policyfile_lock_filename @policyfile_filename = policyfile_lock_filename.sub(/\.lock\.json\Z/, ".rb") @relative_paths_root = File.dirname(policyfile_lock_filename) self end |