Class: RulesView

Inherits:
Object show all
Defined in:
lib/cfn-nag/result_view/rules_view.rb

Overview

View rules warnings/failings

Instance Method Summary collapse

Instance Method Details

#emit(rule_registry, profile, output_format: 'txt') ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cfn-nag/result_view/rules_view.rb', line 7

def emit(rule_registry, profile, output_format: 'txt')
  warnings = select_rules(rule_registry.warnings, profile)
  failings = select_rules(rule_registry.failings, profile)
  rules = failings + warnings
  case output_format
  when 'csv'
    emit_csv(rules)
  when 'json'
    puts rules_to_json(rules)
  when 'txt'
    emit_txt(warnings, failings)
  end

  if rule_registry.duplicate_ids?
    emit_duplicates(rule_registry.duplicate_ids)
    exit 1
  end
end