Class: Bootprint::Report
- Inherits:
-
Object
- Object
- Bootprint::Report
- Defined in:
- lib/bootprint/diagnosis.rb
Instance Attribute Summary collapse
-
#duration_ms ⇒ Object
readonly
Returns the value of attribute duration_ms.
-
#findings ⇒ Object
readonly
Returns the value of attribute findings.
-
#policy ⇒ Object
readonly
Returns the value of attribute policy.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #blocking? ⇒ Boolean
- #counts ⇒ Object
-
#initialize(source:, target:, findings:, policy:, duration_ms:) ⇒ Report
constructor
A new instance of Report.
- #to_h ⇒ Object
Constructor Details
#initialize(source:, target:, findings:, policy:, duration_ms:) ⇒ Report
Returns a new instance of Report.
51 52 53 54 55 56 57 |
# File 'lib/bootprint/diagnosis.rb', line 51 def initialize(source:, target:, findings:, policy:, duration_ms:) @source = source @target = target @findings = findings.sort_by { |finding| [-Rules::SEVERITY_ORDER.fetch(finding.severity), finding.rule_id] } @policy = policy @duration_ms = duration_ms end |
Instance Attribute Details
#duration_ms ⇒ Object (readonly)
Returns the value of attribute duration_ms.
49 50 51 |
# File 'lib/bootprint/diagnosis.rb', line 49 def duration_ms @duration_ms end |
#findings ⇒ Object (readonly)
Returns the value of attribute findings.
49 50 51 |
# File 'lib/bootprint/diagnosis.rb', line 49 def findings @findings end |
#policy ⇒ Object (readonly)
Returns the value of attribute policy.
49 50 51 |
# File 'lib/bootprint/diagnosis.rb', line 49 def policy @policy end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
49 50 51 |
# File 'lib/bootprint/diagnosis.rb', line 49 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
49 50 51 |
# File 'lib/bootprint/diagnosis.rb', line 49 def target @target end |
Instance Method Details
#blocking? ⇒ Boolean
59 |
# File 'lib/bootprint/diagnosis.rb', line 59 def blocking? = findings.any? { |finding| finding.blocking?(policy) } |
#counts ⇒ Object
61 62 63 64 65 66 |
# File 'lib/bootprint/diagnosis.rb', line 61 def counts Rules::Rule::SEVERITIES.to_h do |severity| count = findings.count { |finding| finding.severity == severity && !finding.suppressed } [severity.to_s, count] end end |
#to_h ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/bootprint/diagnosis.rb', line 68 def to_h { "schema_version" => Diagnosis::REPORT_SCHEMA_VERSION, "source" => (source), "target" => (target), "findings" => findings.map(&:to_h), "summary" => counts.merge("blocking" => blocking?), "execution" => { "bootprint_version" => VERSION, "duration_ms" => duration_ms, "network_requests" => 0, "policy" => policy.path } } end |