Class: Inspec::Reporters::Base

Inherits:
Object
  • Object
show all
Includes:
Utils::RunDataFilters
Defined in:
lib/inspec/reporters/base.rb

Direct Known Subclasses

CLI, Json, Yaml

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::RunDataFilters

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

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
# File 'lib/inspec/reporters/base.rb', line 9

def initialize(config)
  @config = config
  @run_data = config[:run_data] || {}
  apply_run_data_filters_to_hash

  @output = ""
end

Instance Attribute Details

#run_dataObject (readonly)

Returns the value of attribute run_data.



7
8
9
# File 'lib/inspec/reporters/base.rb', line 7

def run_data
  @run_data
end

Instance Method Details

#output(str, newline = true) ⇒ Object



17
18
19
20
# File 'lib/inspec/reporters/base.rb', line 17

def output(str, newline = true)
  @output << str
  @output << "\n" if newline
end

#renderObject

each reporter must implement #render

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/inspec/reporters/base.rb', line 27

def render
  raise NotImplementedError, "#{self.class} must implement a `#render` method to format its output."
end

#rendered_outputObject



22
23
24
# File 'lib/inspec/reporters/base.rb', line 22

def rendered_output
  @output
end