Class: Kettle::Drift::LockFile
- Inherits:
-
Object
- Object
- Kettle::Drift::LockFile
- Defined in:
- lib/kettle/drift/lock_file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(path) ⇒ LockFile
constructor
A new instance of LockFile.
- #read_results ⇒ Object
- #write_results(results, project_root: nil) ⇒ Object
Constructor Details
#initialize(path) ⇒ LockFile
Returns a new instance of LockFile.
10 11 12 |
# File 'lib/kettle/drift/lock_file.rb', line 10 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/kettle/drift/lock_file.rb', line 8 def path @path end |
Instance Method Details
#delete ⇒ Object
25 26 27 28 29 |
# File 'lib/kettle/drift/lock_file.rb', line 25 def delete return unless File.exist?(path) File.delete(path) end |
#read_results ⇒ Object
14 15 16 17 18 |
# File 'lib/kettle/drift/lock_file.rb', line 14 def read_results return unless File.exist?(path) Kettle::Drift::Serializer.deserialize(File.read(path, encoding: Encoding::UTF_8)) end |
#write_results(results, project_root: nil) ⇒ Object
20 21 22 23 |
# File 'lib/kettle/drift/lock_file.rb', line 20 def write_results(results, project_root: nil) FileUtils.mkdir_p(File.dirname(path)) File.write(path, Kettle::Drift::Serializer.serialize(results, project_root: project_root), encoding: Encoding::UTF_8) end |