Class: SentinelRb::Report::JsonFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/sentinel_rb/report.rb

Overview

JSON formatter for programmatic consumption

Instance Method Summary collapse

Instance Method Details

#format(results, pretty: true, **_options) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/sentinel_rb/report.rb', line 124

def format(results, pretty: true, **_options)
  require "json"

  output = {
    timestamp: Time.now.iso8601,
    summary: SentinelRb::Analyzer.new.summarize_results(results),
    results: results
  }

  if pretty
    JSON.pretty_generate(output)
  else
    JSON.generate(output)
  end
end