Class: FiberAudit::Reporters::Text
- Defined in:
- lib/fiber_audit/reporters/text.rb
Overview
Text reporter that outputs human-readable audit results. Calls Schema.build then Schema.validate! to enforce the contract.
Exact contract:
- Header:
FiberAudit 0.1.0 — static analysis - Summary counts, suppressed, status
- Disclaimer under status
- Findings: RULE SEVERITY path:line
- Optional: symbol — operation [context]
- message
- (unknown location) fallback
- Footer: Run
fiber-audit explain <RULE_ID>for rule details. - ANSI escape constants only in Text::ANSI
- Color ONLY severity labels, not footer/header
Defined Under Namespace
Modules: ANSI
Instance Method Summary collapse
-
#initialize(color: false) ⇒ Text
constructor
A new instance of Text.
- #render(result) ⇒ Object
Constructor Details
#initialize(color: false) ⇒ Text
Returns a new instance of Text.
60 61 62 63 |
# File 'lib/fiber_audit/reporters/text.rb', line 60 def initialize(color: false) super() @color = color end |
Instance Method Details
#render(result) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/fiber_audit/reporters/text.rb', line 65 def render(result) # Build normalized primitive report hash from result protocol report_hash = Schema.build(result) # Validate the hash (also freezes it) Schema.validate!(report_hash) lines = [] # Header: exact contract lines << header lines << '' # Summary counts and suppressed/status lines << summary_section(report_hash[:summary]) lines << '' # Status lines << status_section(report_hash[:status]) # Mandatory disclaimer under status lines << disclaimer_section lines << '' # Findings lines << findings_section(report_hash[:findings]) lines << '' # Footer hint is always present, including no-findings reports. lines << "#{lines.join("\n").chomp}\n" end |