class Inspec::Plugin::V2::PluginType::Reporter
Attributes
run_data[R]
Public Class Methods
new(config)
click to toggle source
# 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
run_data_schema_constraints()
click to toggle source
# 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
Public Instance Methods
output(str, newline = true)
click to toggle source
# File lib/inspec/plugin/v2/plugin_types/reporter.rb, line 29 def output(str, newline = true) @output << str @output << "\n" if newline end
render()
click to toggle source
each reporter must implement render
# 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()
click to toggle source
# File lib/inspec/plugin/v2/plugin_types/reporter.rb, line 34 def rendered_output @output end