Class: Reviewer::Session::Formatter
- Inherits:
-
Object
- Object
- Reviewer::Session::Formatter
- Includes:
- Output::Formatting
- Defined in:
- lib/reviewer/session/formatter.rb
Overview
Display logic for lifecycle warnings: unrecognized keywords, no matching tools, etc.
Constant Summary
Constants included from Output::Formatting
Output::Formatting::CHECKMARK, Output::Formatting::XMARK
Instance Method Summary collapse
-
#git_error(message) ⇒ void
Displays a git-related error with context-appropriate messaging.
-
#initialize(output) ⇒ Formatter
constructor
Creates a formatter for session lifecycle warnings.
-
#invalid_format(value, known) ⇒ void
Displays a warning when an unrecognized output format is requested.
-
#no_matching_tools(requested:, available:) ⇒ void
Displays a warning when no configured tools match the requested names or tags.
-
#no_reviewable_files(keywords:) ⇒ void
Displays a message when file-scoping keywords resolved to no files.
-
#unrecognized_keywords(unrecognized, suggestions) ⇒ void
Displays warnings for keywords that don’t match any tool or git scope.
Constructor Details
#initialize(output) ⇒ Formatter
Creates a formatter for session lifecycle warnings
18 19 20 21 |
# File 'lib/reviewer/session/formatter.rb', line 18 def initialize(output) @output = output @printer = output.printer end |
Instance Method Details
#git_error(message) ⇒ void
This method returns an undefined value.
Displays a git-related error with context-appropriate messaging
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/reviewer/session/formatter.rb', line 52 def git_error() if .include?('not a git repository') printer.puts(:warning, 'Not a git repository') printer.puts(:muted, 'Git keywords (staged, modified, etc.) require a git repository') else printer.puts(:warning, 'Git command failed') printer.puts(:muted, ) printer.puts(:muted, 'Continuing without file filtering') end end |
#invalid_format(value, known) ⇒ void
This method returns an undefined value.
Displays a warning when an unrecognized output format is requested
42 43 44 45 46 |
# File 'lib/reviewer/session/formatter.rb', line 42 def invalid_format(value, known) printer.puts(:warning, "Unknown format '#{value}', using 'streaming'") printer.puts(:muted, "Valid formats: #{known.join(', ')}") output.newline end |
#no_matching_tools(requested:, available:) ⇒ void
This method returns an undefined value.
Displays a warning when no configured tools match the requested names or tags
78 79 80 81 82 83 84 |
# File 'lib/reviewer/session/formatter.rb', line 78 def no_matching_tools(requested:, available:) output.newline printer.puts(:warning, 'No matching tools found') printer.puts(:muted, "Requested: #{requested.join(', ')}") if requested.any? printer.puts(:muted, "Available: #{available.join(', ')}") if available.any? output.newline end |
#no_reviewable_files(keywords:) ⇒ void
This method returns an undefined value.
Displays a message when file-scoping keywords resolved to no files
67 68 69 70 71 |
# File 'lib/reviewer/session/formatter.rb', line 67 def no_reviewable_files(keywords:) output.newline printer.puts(:muted, "No reviewable #{keywords.join(', ')} files found") output.newline end |
#unrecognized_keywords(unrecognized, suggestions) ⇒ void
This method returns an undefined value.
Displays warnings for keywords that don’t match any tool or git scope
28 29 30 31 32 33 34 35 |
# File 'lib/reviewer/session/formatter.rb', line 28 def unrecognized_keywords(unrecognized, suggestions) unrecognized.each do |keyword| printer.puts(:warning, "Unrecognized: #{keyword}") suggestion = suggestions[keyword] printer.puts(:muted, " did you mean '#{suggestion}'?") if suggestion end output.newline end |