Class: Reviewer::Doctor::Report
- Inherits:
-
Object
- Object
- Reviewer::Doctor::Report
- Defined in:
- lib/reviewer/doctor/report.rb
Overview
Structured container for diagnostic findings organized by section
Defined Under Namespace
Classes: Finding
Constant Summary collapse
- SECTIONS =
Ordered list of report sections
i[configuration tools opportunities environment].freeze
Instance Attribute Summary collapse
-
#findings ⇒ Object
readonly
Returns the value of attribute findings.
Instance Method Summary collapse
-
#add(section, status:, message:, detail: nil) ⇒ Object
Adds a finding to a section.
-
#errors ⇒ Object
All error findings across sections.
-
#initialize ⇒ Report
constructor
A new instance of Report.
-
#ok? ⇒ Boolean
Whether all findings are free of errors.
-
#section(name) ⇒ Array<Finding>
Findings for a specific section.
-
#warnings ⇒ Object
All warning findings across sections.
Constructor Details
#initialize ⇒ Report
Returns a new instance of Report.
21 22 23 |
# File 'lib/reviewer/doctor/report.rb', line 21 def initialize @findings = Hash.new { |hash, key| hash[key] = [] } end |
Instance Attribute Details
#findings ⇒ Object (readonly)
Returns the value of attribute findings.
19 20 21 |
# File 'lib/reviewer/doctor/report.rb', line 19 def findings @findings end |
Instance Method Details
#add(section, status:, message:, detail: nil) ⇒ Object
Adds a finding to a section
30 31 32 |
# File 'lib/reviewer/doctor/report.rb', line 30 def add(section, status:, message:, detail: nil) findings[section] << Finding.new(status: status, message: , detail: detail) end |
#errors ⇒ Object
All error findings across sections
40 41 42 |
# File 'lib/reviewer/doctor/report.rb', line 40 def errors all_findings.select { |finding| finding.status == :error } end |
#ok? ⇒ Boolean
Whether all findings are free of errors
35 36 37 |
# File 'lib/reviewer/doctor/report.rb', line 35 def ok? all_findings.none? { |finding| finding.status == :error } end |
#section(name) ⇒ Array<Finding>
Findings for a specific section
52 53 54 |
# File 'lib/reviewer/doctor/report.rb', line 52 def section(name) findings[name] end |
#warnings ⇒ Object
All warning findings across sections
45 46 47 |
# File 'lib/reviewer/doctor/report.rb', line 45 def warnings all_findings.select { |finding| finding.status == :warning } end |