Class: Reviewer::Runner::Formatter
- Inherits:
-
Object
- Object
- Reviewer::Runner::Formatter
- Includes:
- Output::Formatting
- Defined in:
- lib/reviewer/runner/formatter.rb
Overview
Display logic for tool execution: tool identity, success, failure, skipped, guidance
Constant Summary
Constants included from Output::Formatting
Output::Formatting::CHECKMARK, Output::Formatting::XMARK
Instance Method Summary collapse
-
#current_command(command) ⇒ void
Displays the exact command string being executed for debugging and copy/paste.
-
#failure(details, command: nil) ⇒ void
Displays a failure message with details and optionally the failed command.
-
#guidance(summary, details) ⇒ void
Displays contextual guidance after a failure to help the user recover.
-
#initialize(output) ⇒ Formatter
constructor
Creates a formatter for runner-specific display.
-
#skipped(reason = 'no matching files') ⇒ void
Displays a skip notice with the reason.
-
#success(timer) ⇒ void
Displays a success message with timing breakdown.
-
#tool_summary(tool) ⇒ void
Prints the tool name and description as a header before execution.
-
#unrecoverable(details) ⇒ void
Displays an unrecoverable error that prevents further execution.
Constructor Details
#initialize(output) ⇒ Formatter
Creates a formatter for runner-specific display
18 19 20 21 |
# File 'lib/reviewer/runner/formatter.rb', line 18 def initialize(output) @output = output @printer = output.printer end |
Instance Method Details
#current_command(command) ⇒ void
This method returns an undefined value.
Displays the exact command string being executed for debugging and copy/paste
36 37 38 39 40 |
# File 'lib/reviewer/runner/formatter.rb', line 36 def current_command(command) printer.print(:default, ' ↳ ') printer.puts(:muted, String(command)) output.newline end |
#failure(details, command: nil) ⇒ void
This method returns an undefined value.
Displays a failure message with details and optionally the failed command
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/reviewer/runner/formatter.rb', line 69 def failure(details, command: nil) printer.print(:failure, 'Failure') printer.puts(:muted, " #{details}") return unless command output.newline printer.puts(:bold, 'Failed Command:') printer.puts(:muted, String(command)) end |
#guidance(summary, details) ⇒ void
This method returns an undefined value.
Displays contextual guidance after a failure to help the user recover
94 95 96 97 98 99 100 |
# File 'lib/reviewer/runner/formatter.rb', line 94 def guidance(summary, details) return unless details output.newline printer.puts(:bold, summary) printer.puts(:muted, details) end |
#skipped(reason = 'no matching files') ⇒ void
This method returns an undefined value.
Displays a skip notice with the reason
58 59 60 61 62 |
# File 'lib/reviewer/runner/formatter.rb', line 58 def skipped(reason = 'no matching files') printer.print(:muted, 'Skipped') printer.puts(:muted, " (#{reason})") output.newline end |
#success(timer) ⇒ void
This method returns an undefined value.
Displays a success message with timing breakdown
46 47 48 49 50 51 52 |
# File 'lib/reviewer/runner/formatter.rb', line 46 def success(timer) printer.print(:success, 'Success') printer.print(:success_light, " #{timer.total_seconds}s") printer.print(:warning_light, " (#{timer.prep_percent}% prep ~#{timer.prep_seconds}s)") if timer.prepped? output.newline output.newline end |
#tool_summary(tool) ⇒ void
This method returns an undefined value.
Prints the tool name and description as a header before execution
27 28 29 30 |
# File 'lib/reviewer/runner/formatter.rb', line 27 def tool_summary(tool) printer.print(:bold, tool.name) printer.puts(:muted, " #{tool.description}") end |
#unrecoverable(details) ⇒ void
This method returns an undefined value.
Displays an unrecoverable error that prevents further execution
84 85 86 87 |
# File 'lib/reviewer/runner/formatter.rb', line 84 def unrecoverable(details) printer.puts(:error, 'Unrecoverable Error:') printer.puts(:muted, details) end |