Class: Mutant::Result::JSONWriter Private
- Inherits:
-
Object
- Object
- Mutant::Result::JSONWriter
- Defined in:
- lib/mutant/result/json_writer.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Write result JSON to .mutant/results/
Constant Summary collapse
- RESULTS_DIR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'.mutant/results'
Instance Method Summary collapse
-
#call ⇒ Pathname
private
Write result JSON file.
Instance Method Details
#call ⇒ Pathname
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Write result JSON file
Written to a temporary file first and renamed into place, so a concurrent reader of the session file never observes a partial document. This matters once the file is rewritten during a run.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mutant/result/json_writer.rb', line 18 def call dir = env.world.pathname.new(RESULTS_DIR) dir.mkpath path = dir.join("#{SESSION_ID}.json") tmp_path = dir.join("#{SESSION_ID}.json.tmp") tmp_path.write(json) tmp_path.rename(path) path end |