Class: Menuconform::Report
- Inherits:
-
Object
- Object
- Menuconform::Report
- Defined in:
- lib/menuconform/report.rb
Overview
Machine-readable conformance report: score, breakdown, and findings enriched with catalog titles and fix hints. Contains no wall-clock timestamp of its own — reference_time is the only time input, and it is stated so the report is reproducible.
Instance Attribute Summary collapse
-
#catalog ⇒ Object
readonly
Returns the value of attribute catalog.
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#findings ⇒ Object
readonly
Returns the value of attribute findings.
-
#reference_time ⇒ Object
readonly
Returns the value of attribute reference_time.
Instance Method Summary collapse
-
#initialize(doc:, findings:, catalog:, reference_time:) ⇒ Report
constructor
A new instance of Report.
- #score ⇒ Object
- #score_breakdown ⇒ Object
- #to_h ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(doc:, findings:, catalog:, reference_time:) ⇒ Report
Returns a new instance of Report.
13 14 15 16 17 18 |
# File 'lib/menuconform/report.rb', line 13 def initialize(doc:, findings:, catalog:, reference_time:) @doc = doc @findings = findings @catalog = catalog @reference_time = reference_time end |
Instance Attribute Details
#catalog ⇒ Object (readonly)
Returns the value of attribute catalog.
11 12 13 |
# File 'lib/menuconform/report.rb', line 11 def catalog @catalog end |
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
11 12 13 |
# File 'lib/menuconform/report.rb', line 11 def doc @doc end |
#findings ⇒ Object (readonly)
Returns the value of attribute findings.
11 12 13 |
# File 'lib/menuconform/report.rb', line 11 def findings @findings end |
#reference_time ⇒ Object (readonly)
Returns the value of attribute reference_time.
11 12 13 |
# File 'lib/menuconform/report.rb', line 11 def reference_time @reference_time end |
Instance Method Details
#score ⇒ Object
21 |
# File 'lib/menuconform/report.rb', line 21 def score = score_breakdown["score"] |
#score_breakdown ⇒ Object
20 |
# File 'lib/menuconform/report.rb', line 20 def score_breakdown = @score_breakdown ||= Scorer.score(findings) |
#to_h ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/menuconform/report.rb', line 23 def to_h { "menuconform_version" => VERSION, "rules_version" => catalog.rules_version, "reference_time" => reference_time.utc.iso8601, "menu" => { "name" => doc["name"], "ir_version" => doc["ir_version"], "currency" => doc["currency"], "timezone" => doc["timezone"] }, "score" => score, "score_breakdown" => score_breakdown.except("score"), "severity_counts" => severity_counts, "findings" => findings.map { |f| enrich(f) } } end |
#to_json(*args) ⇒ Object
41 42 43 |
# File 'lib/menuconform/report.rb', line 41 def to_json(*args) JSON.pretty_generate(to_h, *args) end |