Class: Mutant::Result::JSONWriter Private

Inherits:
Object
  • Object
show all
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/, gzip compressed

Constant Summary collapse

EMPTY_LOG =

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.

Log stored in place of the log of a covered mutation

LogCapture::String.new(content: '')

Instance Method Summary collapse

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

The JSON repeats the source, diff, and tests of each mutation, and compresses about twentyfold.

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.

Returns:

  • (Pathname)


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mutant/result/json_writer.rb', line 22

def call
  dir = env.world.pathname.new(SessionFiles::DIRECTORY)
  dir.mkpath

  path = dir.join("#{SESSION_ID}.json.gz")
  tmp_path = dir.join("#{SESSION_ID}.json.gz.tmp")
  tmp_path.binwrite(Zlib.gzip(json))
  tmp_path.rename(path)

  path
end