Class: InspecTools::Summary

Inherits:
Object show all
Defined in:
lib/inspec_tools/summary.rb

Instance Method Summary collapse

Constructor Details

#initialize(inspec_json) ⇒ Summary

Returns a new instance of Summary.



20
21
22
# File 'lib/inspec_tools/summary.rb', line 20

def initialize(inspec_json)
  @json = JSON.parse(inspec_json)
end

Instance Method Details

#threshold(threshold = nil) ⇒ Object



36
37
38
39
40
41
# File 'lib/inspec_tools/summary.rb', line 36

def threshold(threshold = nil)
  @summary = to_summary
  @threshold = Utils::InspecUtil.to_dotted_hash(YAML.load_file(THRESHOLD_TEMPLATE))
  parse_threshold(Utils::InspecUtil.to_dotted_hash(threshold))
  threshold_compliance
end

#to_summaryObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/inspec_tools/summary.rb', line 24

def to_summary
  @data = Utils::InspecUtil.parse_data_for_ckl(@json)
  @summary = {}
  @data.keys.each do |control_id|
    current_control = @data[control_id]
    current_control[:compliance_status] = Utils::InspecUtil.control_status(current_control, true)
    current_control[:finding_details] = Utils::InspecUtil.control_finding_details(current_control, current_control[:compliance_status])
  end
  compute_summary
  @summary
end