Class: RosettAi::Comply::Reporter
- Inherits:
-
Object
- Object
- RosettAi::Comply::Reporter
- Defined in:
- lib/rosett_ai/comply/reporter.rb
Overview
Formats compliance check results for display.
TTY-aware: coloured table when interactive, plain text when piped. Supports JSON output mode for CI integration.
Instance Method Summary collapse
-
#exit_code ⇒ Integer
Computes exit code from results.
-
#initialize(results:, format: 'table', output: $stdout) ⇒ Reporter
constructor
A new instance of Reporter.
-
#report
Renders the compliance report.
Constructor Details
#initialize(results:, format: 'table', output: $stdout) ⇒ Reporter
Returns a new instance of Reporter.
23 24 25 26 27 |
# File 'lib/rosett_ai/comply/reporter.rb', line 23 def initialize(results:, format: 'table', output: $stdout) @results = results @format = format @output = output end |
Instance Method Details
#exit_code ⇒ Integer
Computes exit code from results.
42 43 44 45 46 47 |
# File 'lib/rosett_ai/comply/reporter.rb', line 42 def exit_code return 2 if @results.any? { |r| r[:status] == 'fail' } return 1 if @results.any? { |r| r[:status] == 'warn' } 0 end |
#report
This method returns an undefined value.
Renders the compliance report.
32 33 34 35 36 37 |
# File 'lib/rosett_ai/comply/reporter.rb', line 32 def report case @format when 'json' then report_json else report_table end end |