Class: GitFit::Dedup::LogWriter
- Inherits:
-
Object
- Object
- GitFit::Dedup::LogWriter
- Defined in:
- lib/git_fit/dedup/log_writer.rb
Instance Method Summary collapse
-
#initialize(log_path = nil) ⇒ LogWriter
constructor
A new instance of LogWriter.
- #write(stats:, matches:, elapsed:) ⇒ Object
Constructor Details
#initialize(log_path = nil) ⇒ LogWriter
Returns a new instance of LogWriter.
9 10 11 12 |
# File 'lib/git_fit/dedup/log_writer.rb', line 9 def initialize(log_path = nil) @log_path = log_path || default_path FileUtils.mkdir_p(File.dirname(@log_path)) end |
Instance Method Details
#write(stats:, matches:, elapsed:) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/git_fit/dedup/log_writer.rb', line 14 def write(stats:, matches:, elapsed:) log = { started_at: (Time.now.utc - elapsed).iso8601, elapsed_seconds: elapsed.round(1), stats: stats, matches: matches, } File.write(@log_path, JSON.pretty_generate(log)) @log_path end |