Class: Guardrails::Report::Summary
- Inherits:
-
Object
- Object
- Guardrails::Report::Summary
- Defined in:
- lib/guardrails/report/summary.rb
Overview
Top-of-report triage view. Builds a grouped severity rollup from the audit’s per-detector counts, so the reader sees the shape of the findings before scrolling through the per-section detail.
Each detector contributes one Entry. The rake task assembles the full list after running its sub-audits and hands it to Summary. Detector logic isn’t aware of the report; Summary doesn’t know about specific detectors. That decoupling matters when we add new detectors — they only need to register an Entry.
Defined Under Namespace
Classes: Entry
Constant Summary collapse
- SEVERITY_ORDER =
Severity order in the report: errors first (urgent), warnings next (probably-fix), suggestions last (consider).
%i[error warning suggestion].freeze
Instance Method Summary collapse
-
#initialize(entries:, output:, style: nil) ⇒ Summary
constructor
A new instance of Summary.
- #render(recap: false) ⇒ Object
Constructor Details
#initialize(entries:, output:, style: nil) ⇒ Summary
Returns a new instance of Summary.
31 32 33 34 35 |
# File 'lib/guardrails/report/summary.rb', line 31 def initialize(entries:, output:, style: nil) @entries = entries.reject { |e| e.count.zero? } @output = output @style = style || Style.new(io: output) end |
Instance Method Details
#render(recap: false) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/guardrails/report/summary.rb', line 37 def render(recap: false) return if @entries.empty? @output.puts "" @output.puts header_line(recap: recap) @output.puts "" SEVERITY_ORDER.each do |severity| group = @entries.select { |e| e.severity == severity } next if group.empty? render_severity_group(severity, group) end @output.puts divider end |