Module: Bundler::Audit::CLI::Formats::JSON

Defined in:
lib/bundler/audit/cli/formats/json.rb

Overview

The JSON output format.

Instance Method Summary collapse

Instance Method Details

#criticality_label(advisory) ⇒ Object



49
50
51
52
53
54
55
56
57
58
# File 'lib/bundler/audit/cli/formats/json.rb', line 49

def criticality_label(advisory)
  case advisory.criticality
  when :none     then "none"
  when :low      then "low"
  when :medium   then "medium"
  when :high     then "high"
  when :critical then "critical"
  else "unknown"
  end
end

Outputs the report as JSON. Will pretty-print JSON if output is a TTY, otherwise normal JSON will be outputted.

Parameters:

  • report (Report)

    The results from the Scanner.

  • output (IO, File) (defaults to: $stdout)

    The output stream.



39
40
41
42
43
44
45
46
47
# File 'lib/bundler/audit/cli/formats/json.rb', line 39

def print_report(report,output=$stdout)
  hash = report.to_h

  if output.tty?
    output.puts(::JSON.pretty_generate(hash))
  else
    output.write(::JSON.generate(hash))
  end
end