Class: Rigor::CLI::TriageRenderer
- Inherits:
-
Object
- Object
- Rigor::CLI::TriageRenderer
- Defined in:
- lib/rigor/cli/triage_renderer.rb
Overview
ADR-23 — renders a Triage::Report as the ‘rigor triage` text report or as `–format json`.
Constant Summary collapse
- BAR_WIDTH =
24
Instance Method Summary collapse
-
#initialize(report, sections:) ⇒ TriageRenderer
constructor
A new instance of TriageRenderer.
- #json ⇒ Object
- #text ⇒ Object
Constructor Details
#initialize(report, sections:) ⇒ TriageRenderer
Returns a new instance of TriageRenderer.
14 15 16 17 |
# File 'lib/rigor/cli/triage_renderer.rb', line 14 def initialize(report, sections:) @report = report @sections = sections # subset of %i[distribution hotspots hints] end |
Instance Method Details
#json ⇒ Object
19 20 21 |
# File 'lib/rigor/cli/triage_renderer.rb', line 19 def json JSON.pretty_generate(Triage.report_to_h(@report)) end |
#text ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/rigor/cli/triage_renderer.rb', line 23 def text blocks = [] blocks << distribution_block if @sections.include?(:distribution) blocks << hotspots_block if @sections.include?(:hotspots) blocks << hints_block if @sections.include?(:hints) "#{blocks.join("\n\n")}\n" end |