Class: Inspec::Reporters::Json

Inherits:
Base
  • Object
show all
Defined in:
lib/inspec/reporters/json.rb

Overview

rubocop:disable Layout/AlignHash, Style/BlockDelimiters

Direct Known Subclasses

JsonAutomate

Instance Attribute Summary

Attributes inherited from Base

#enhanced_outcomes, #run_data

Instance Method Summary collapse

Methods inherited from Base

#initialize, #output, #rendered_output

Methods included from Utils::RunDataFilters

#apply_report_resize_options, #apply_run_data_filters_to_hash, #filter_empty_profiles, #redact_sensitive_inputs, #sort_controls, #suppress_diff_output

Constructor Details

This class inherits a constructor from Inspec::Reporters::Base

Instance Method Details

#renderObject



6
7
8
# File 'lib/inspec/reporters/json.rb', line 6

def render
  output(report.to_json, false)
end

#reportObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/inspec/reporters/json.rb', line 10

def report
  output = {
    platform: platform,
    profiles: profiles,
    statistics: {
      duration: run_data[:statistics][:duration],
    },
    version: run_data[:version],
  }

  %w{passthrough}.each do |option|
    output[option.to_sym] = @config[option] unless @config[option].nil?
  end
  output
end