Class: Inspec::Plugin::V2::PluginType::Reporter
- Inherits:
-
Inspec::Plugin::V2::PluginBase
- Object
- Inspec::Plugin::V2::PluginBase
- Inspec::Plugin::V2::PluginType::Reporter
- Includes:
- Utils::RunDataFilters
- Defined in:
- lib/inspec/plugin/v2/plugin_types/reporter.rb
Instance Attribute Summary collapse
-
#enhanced_outcomes ⇒ Object
Returns the value of attribute enhanced_outcomes.
-
#run_data ⇒ Object
readonly
Returns the value of attribute run_data.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config) ⇒ Reporter
constructor
A new instance of Reporter.
- #output(str, newline = true) ⇒ Object
-
#render ⇒ Object
each reporter must implement #render.
- #rendered_output ⇒ Object
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
Methods inherited from Inspec::Plugin::V2::PluginBase
base_class_for_type, find_name_by_implementation_class, plugin_name, register_plugin_type, registry
Constructor Details
#initialize(config) ⇒ Reporter
Returns a new instance of Reporter.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/inspec/plugin/v2/plugin_types/reporter.rb', line 12 def initialize(config) @config = config # Filter the run_data while still a Hash; if it is huge, this # saves on conversion time @run_data = config[:run_data] || {} apply_run_data_filters_to_hash unless Inspec::RunData.compatible_schema?(self.class.run_data_schema_constraints) # Best we can do is warn here, the InSpec run has finished # TODO: one day, perhaps switch RunData implementations to try to satisfy constraints? Inspec::Log.warn "Reporter does not support RunData API (#{Inspec::RunData::SCHEMA_VERSION}), Reporter constraints: '#{self.class.run_data_schema_constraints}'" end # Convert to RunData object for consumption by Reporter @run_data = Inspec::RunData.new(@run_data) @output = "" end |
Instance Attribute Details
#enhanced_outcomes ⇒ Object
Returns the value of attribute enhanced_outcomes.
10 11 12 |
# File 'lib/inspec/plugin/v2/plugin_types/reporter.rb', line 10 def enhanced_outcomes @enhanced_outcomes end |
#run_data ⇒ Object (readonly)
Returns the value of attribute run_data.
9 10 11 |
# File 'lib/inspec/plugin/v2/plugin_types/reporter.rb', line 9 def run_data @run_data end |
Class Method Details
.run_data_schema_constraints ⇒ Object
44 45 46 |
# File 'lib/inspec/plugin/v2/plugin_types/reporter.rb', line 44 def self.run_data_schema_constraints raise NotImplementedError, "#{self.class} must implement a `run_data_schema_constraints` class method to declare its compatibiltity with the RunData API." end |
Instance Method Details
#output(str, newline = true) ⇒ Object
30 31 32 33 |
# File 'lib/inspec/plugin/v2/plugin_types/reporter.rb', line 30 def output(str, newline = true) @output << str @output << "\n" if newline end |
#render ⇒ Object
each reporter must implement #render
40 41 42 |
# File 'lib/inspec/plugin/v2/plugin_types/reporter.rb', line 40 def render raise NotImplementedError, "#{self.class} must implement a `#render` method to format its output." end |
#rendered_output ⇒ Object
35 36 37 |
# File 'lib/inspec/plugin/v2/plugin_types/reporter.rb', line 35 def rendered_output @output end |