Class: Dobby::Formatter::JSONFormatter

Inherits:
AbstractFormatter show all
Defined in:
lib/dobby/formatter/json_formatter.rb

Overview

Outputs results as JSON

Instance Attribute Summary

Attributes inherited from AbstractFormatter

#options, #output

Instance Method Summary collapse

Methods inherited from AbstractFormatter

#initialize

Constructor Details

This class inherits a constructor from Dobby::Formatter::AbstractFormatter

Instance Method Details

#file_finished(file, results) ⇒ Object



15
16
17
18
19
# File 'lib/dobby/formatter/json_formatter.rb', line 15

def file_finished(file, results)
  return if results.empty?

  @results[file] = each_completed_result(results)
end

#file_started(file) ⇒ Object



11
12
13
# File 'lib/dobby/formatter/json_formatter.rb', line 11

def file_started(file)
  @results[file] = []
end

#finished(_files) ⇒ Object



21
22
23
# File 'lib/dobby/formatter/json_formatter.rb', line 21

def finished(_files)
  output.puts(Oj.dump(@results, mode: :strict))
end

#started(_target_files) ⇒ Object



7
8
9
# File 'lib/dobby/formatter/json_formatter.rb', line 7

def started(_target_files)
  @results = {}
end