Class: Kettle::Drift::LockFile

Inherits:
Object
  • Object
show all
Defined in:
lib/kettle/drift/lock_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathObject (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

#deleteObject



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_resultsObject



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