Class: RuboCop::Gradual::LockFile
- Inherits:
-
Object
- Object
- RuboCop::Gradual::LockFile
- Defined in:
- lib/rubocop/gradual/lock_file.rb
Overview
LockFile class handles reading and writing of lock file.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #delete ⇒ Object
- #diff(new_results) ⇒ Object
-
#initialize(path) ⇒ LockFile
constructor
A new instance of LockFile.
- #read_results ⇒ Object
- #write_results(results) ⇒ Object
Constructor Details
#initialize(path) ⇒ LockFile
Returns a new instance of LockFile.
13 14 15 |
# File 'lib/rubocop/gradual/lock_file.rb', line 13 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/rubocop/gradual/lock_file.rb', line 11 def path @path end |
Instance Method Details
#delete ⇒ Object
23 24 25 26 27 |
# File 'lib/rubocop/gradual/lock_file.rb', line 23 def delete return unless File.exist?(path) File.delete(path) end |
#diff(new_results) ⇒ Object
33 34 35 |
# File 'lib/rubocop/gradual/lock_file.rb', line 33 def diff(new_results) Diffy::Diff.new(Serializer.serialize(new_results), content, context: 0) end |
#read_results ⇒ Object
17 18 19 20 21 |
# File 'lib/rubocop/gradual/lock_file.rb', line 17 def read_results return unless File.exist?(path) Serializer.deserialize(content) end |
#write_results(results) ⇒ Object
29 30 31 |
# File 'lib/rubocop/gradual/lock_file.rb', line 29 def write_results(results) File.write(path, Serializer.serialize(results), encoding: Encoding::UTF_8) end |