class Inspec::Reporters::CLI::Control
Attributes
data[R]
Public Class Methods
new(control_hash)
click to toggle source
# File lib/inspec/reporters/cli.rb, line 354 def initialize(control_hash) @data = control_hash end
Public Instance Methods
anonymous?()
click to toggle source
# File lib/inspec/reporters/cli.rb, line 378 def anonymous? id.start_with?("(generated from ") end
failure_count()
click to toggle source
# File lib/inspec/reporters/cli.rb, line 425 def failure_count results.select { |r| r[:status] == "failed" }.size end
id()
click to toggle source
# File lib/inspec/reporters/cli.rb, line 358 def id data[:id] end
impact()
click to toggle source
# File lib/inspec/reporters/cli.rb, line 370 def impact data[:impact] end
impact_string()
click to toggle source
# File lib/inspec/reporters/cli.rb, line 399 def impact_string if anonymous? nil elsif impact.nil? "unknown" elsif results&.find { |r| r[:status] == "skipped" } "skipped" elsif results.nil? || results.empty? || results.all? { |r| r[:status] == "passed" } "passed" else "failed" end end
impact_string_for_result(result)
click to toggle source
# File lib/inspec/reporters/cli.rb, line 413 def impact_string_for_result(result) if result[:status] == "skipped" "skipped" elsif result[:status] == "passed" "passed" elsif impact.nil? "unknown" else "failed" end end
results()
click to toggle source
# File lib/inspec/reporters/cli.rb, line 366 def results data[:results] end
skipped_count()
click to toggle source
# File lib/inspec/reporters/cli.rb, line 429 def skipped_count results.select { |r| r[:status] == "skipped" }.size end
source_location()
click to toggle source
# File lib/inspec/reporters/cli.rb, line 374 def source_location data[:source_location] end
title()
click to toggle source
# File lib/inspec/reporters/cli.rb, line 362 def title data[:title] end
title_for_report()
click to toggle source
# File lib/inspec/reporters/cli.rb, line 382 def title_for_report # if this is an anonymous control, just grab the resource title from any result entry return results.first[:resource_title] if anonymous? title_for_report = "#{id}: #{title || results.first[:resource_title]}" # we will not add any additional data to the title if there's only # zero or one test for this control. return title_for_report if results.nil? || results.size <= 1 # append a failure summary if appropriate. title_for_report += " (#{failure_count} failed)" if failure_count > 0 title_for_report += " (#{skipped_count} skipped)" if skipped_count > 0 title_for_report end