Class: YamlTransformer
- Inherits:
-
Object
- Object
- YamlTransformer
- Defined in:
- lib/audit/lib/transformers/yaml_transformer.rb
Overview
To change this template, choose Tools | Templates and open the template in the editor.
Class Method Summary collapse
- .transform(report) ⇒ Object
- .transform_benchmark(report, node) ⇒ Object
- .transform_check(check) ⇒ Object
- .transform_group(report, node) ⇒ Object
- .transform_node(report, node) ⇒ Object
- .transform_rule_result(report, node) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ YamlTransformer
constructor
A new instance of YamlTransformer.
Constructor Details
#initialize ⇒ YamlTransformer
Returns a new instance of YamlTransformer.
5 6 7 |
# File 'lib/audit/lib/transformers/yaml_transformer.rb', line 5 def initialize end |
Class Method Details
.transform(report) ⇒ Object
9 10 11 |
# File 'lib/audit/lib/transformers/yaml_transformer.rb', line 9 def self.transform(report) self.transform_node(report, report.get_root) end |
.transform_benchmark(report, node) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/audit/lib/transformers/yaml_transformer.rb', line 25 def self.transform_benchmark(report, node) return {:id => node.id, :name => node.name, :description => node.description, :children => node.children.map {|x| self.transform_node(report, report.get(x.id))}} end |
.transform_check(check) ⇒ Object
47 48 49 |
# File 'lib/audit/lib/transformers/yaml_transformer.rb', line 47 def self.transform_check(check) return check.to_hash() end |
.transform_group(report, node) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/audit/lib/transformers/yaml_transformer.rb', line 32 def self.transform_group(report, node) return {:id => node.id, :name => node.name, :description => node.description, :children => node.children.map {|x| self.transform_node(report, report.get(x.id))}} end |
.transform_node(report, node) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/audit/lib/transformers/yaml_transformer.rb', line 13 def self.transform_node(report, node) if node.kind_of? AuditBenchmark then return self.transform_benchmark(report, node) elsif node.kind_of? Group then return self.transform_group(report, node) elsif node.kind_of? RuleResult then return self.transform_rule_result(report, node) else raise "Unknown report node type #{node.class.name}" end end |
.transform_rule_result(report, node) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/audit/lib/transformers/yaml_transformer.rb', line 39 def self.transform_rule_result(report, node) return {:rule_refid => node.rule.id, :name => node.rule.name, :description => node.rule.description, :check => node.check.map {|x| self.transform_check(x)} } end |