Class: ChefCLI::Policyfile::ComparisonBase::Local
- Inherits:
-
Object
- Object
- ChefCLI::Policyfile::ComparisonBase::Local
- Defined in:
- lib/chef-cli/policyfile/comparison_base.rb
Instance Attribute Summary collapse
-
#policyfile_lock_relpath ⇒ Object
readonly
Returns the value of attribute policyfile_lock_relpath.
Instance Method Summary collapse
-
#initialize(policyfile_lock_relpath) ⇒ Local
constructor
A new instance of Local.
- #lock ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(policyfile_lock_relpath) ⇒ Local
Returns a new instance of Local.
34 35 36 |
# File 'lib/chef-cli/policyfile/comparison_base.rb', line 34 def initialize(policyfile_lock_relpath) @policyfile_lock_relpath = policyfile_lock_relpath end |
Instance Attribute Details
#policyfile_lock_relpath ⇒ Object (readonly)
Returns the value of attribute policyfile_lock_relpath.
32 33 34 |
# File 'lib/chef-cli/policyfile/comparison_base.rb', line 32 def policyfile_lock_relpath @policyfile_lock_relpath end |
Instance Method Details
#lock ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/chef-cli/policyfile/comparison_base.rb', line 42 def lock raise LockfileNotFound, "Expected lockfile at #{policyfile_lock_relpath} does not exist" unless File.exist?(policyfile_lock_relpath) raise LockfileNotFound, "Expected lockfile at #{policyfile_lock_relpath} cannot be read" unless File.readable?(policyfile_lock_relpath) FFI_Yajl::Parser.parse(IO.read(policyfile_lock_relpath)) rescue FFI_Yajl::ParseError => e raise MalformedLockfile, "Invalid JSON in lockfile at #{policyfile_lock_relpath}:\n #{e.}" end |
#name ⇒ Object
38 39 40 |
# File 'lib/chef-cli/policyfile/comparison_base.rb', line 38 def name "local:#{policyfile_lock_relpath}" end |