Class: Umami::Policyfile::PolicyfileLock
- Inherits:
-
Object
- Object
- Umami::Policyfile::PolicyfileLock
- Defined in:
- lib/chef-umami/policyfile/policyfile_lock.rb
Instance Attribute Summary collapse
-
#policyfile ⇒ Object
readonly
Returns the value of attribute policyfile.
Instance Method Summary collapse
-
#initialize(policyfile = nil) ⇒ PolicyfileLock
constructor
A new instance of PolicyfileLock.
- #lock_data ⇒ Object
- #name ⇒ Object
- #policyfile_lock ⇒ Object
- #policyfile_lock_content ⇒ Object
- #policyfile_lock_path ⇒ Object
- #storage_config ⇒ Object
- #ui ⇒ Object
Constructor Details
#initialize(policyfile = nil) ⇒ PolicyfileLock
Returns a new instance of PolicyfileLock.
23 24 25 26 27 28 |
# File 'lib/chef-umami/policyfile/policyfile_lock.rb', line 23 def initialize(policyfile = nil) @policyfile = policyfile @policyfile_lock = nil @storage_config = storage_config @ui = ui end |
Instance Attribute Details
#policyfile ⇒ Object (readonly)
Returns the value of attribute policyfile.
22 23 24 |
# File 'lib/chef-umami/policyfile/policyfile_lock.rb', line 22 def policyfile @policyfile end |
Instance Method Details
#lock_data ⇒ Object
46 47 48 |
# File 'lib/chef-umami/policyfile/policyfile_lock.rb', line 46 def lock_data FFI_Yajl::Parser.new.parse(policyfile_lock_content) end |
#name ⇒ Object
57 58 59 |
# File 'lib/chef-umami/policyfile/policyfile_lock.rb', line 57 def name policyfile_lock.name end |
#policyfile_lock ⇒ Object
50 51 52 53 54 55 |
# File 'lib/chef-umami/policyfile/policyfile_lock.rb', line 50 def policyfile_lock @policyfile_lock ||= ChefDK::PolicyfileLock.new( storage_config, ui: ui ).build_from_lock_data(lock_data) end |
#policyfile_lock_content ⇒ Object
42 43 44 |
# File 'lib/chef-umami/policyfile/policyfile_lock.rb', line 42 def policyfile_lock_content IO.read(policyfile_lock_path) end |
#policyfile_lock_path ⇒ Object
38 39 40 |
# File 'lib/chef-umami/policyfile/policyfile_lock.rb', line 38 def policyfile_lock_path policyfile.gsub(/\.rb$/, '.lock.json') end |
#storage_config ⇒ Object
30 31 32 |
# File 'lib/chef-umami/policyfile/policyfile_lock.rb', line 30 def storage_config @storage_config ||= ChefDK::Policyfile::StorageConfig.new.use_policyfile(policyfile) end |
#ui ⇒ Object
34 35 36 |
# File 'lib/chef-umami/policyfile/policyfile_lock.rb', line 34 def ui @ui ||= ChefDK::UI.new end |