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
-
#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, #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.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/inspec/plugin/v2/plugin_types/reporter.rb', line 11 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
#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
43 44 45 |
# File 'lib/inspec/plugin/v2/plugin_types/reporter.rb', line 43 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
29 30 31 32 |
# File 'lib/inspec/plugin/v2/plugin_types/reporter.rb', line 29 def output(str, newline = true) @output << str @output << "\n" if newline end |
#render ⇒ Object
each reporter must implement #render
39 40 41 |
# File 'lib/inspec/plugin/v2/plugin_types/reporter.rb', line 39 def render raise NotImplementedError, "#{self.class} must implement a `#render` method to format its output." end |
#rendered_output ⇒ Object
34 35 36 |
# File 'lib/inspec/plugin/v2/plugin_types/reporter.rb', line 34 def rendered_output @output end |