Class: Kotoshu::Cli::InteractiveReviewer
- Inherits:
-
Object
- Object
- Kotoshu::Cli::InteractiveReviewer
- Defined in:
- lib/kotoshu/cli/interactive_reviewer.rb
Overview
Interactive review session for spell/grammar checking.
Provides a user-friendly terminal interface for reviewing errors with full navigation support (forward, backward, jump, skip, accept).
Instance Attribute Summary collapse
-
#analyzer ⇒ Object
readonly
Returns the value of attribute analyzer.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#navigation ⇒ Object
readonly
Returns the value of attribute navigation.
Instance Method Summary collapse
-
#has_errors? ⇒ Boolean
Check if session has errors.
-
#initialize(document, analyzer, formatter: nil) ⇒ InteractiveReviewer
constructor
Create a new interactive reviewer.
-
#run ⇒ Hash
Run the interactive review loop.
-
#run_batch ⇒ BatchReporter
Run in batch mode (non-interactive).
-
#statistics ⇒ Hash
Get session statistics.
Constructor Details
#initialize(document, analyzer, formatter: nil) ⇒ InteractiveReviewer
Create a new interactive reviewer.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 29 def initialize(document, analyzer, formatter: nil) raise ArgumentError, "Document required" unless document raise ArgumentError, "Analyzer required" unless analyzer @document = document @analyzer = analyzer # Analyze document for errors errors = @analyzer.analyze(@document) # Create navigation manager @navigation = NavigationManager.new(errors) # Create display formatter @formatter = formatter || DisplayFormatter.new @running = false @show_context = true end |
Instance Attribute Details
#analyzer ⇒ Object (readonly)
Returns the value of attribute analyzer.
22 23 24 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 22 def analyzer @analyzer end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
22 23 24 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 22 def document @document end |
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
22 23 24 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 22 def formatter @formatter end |
#navigation ⇒ Object (readonly)
Returns the value of attribute navigation.
22 23 24 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 22 def @navigation end |
Instance Method Details
#has_errors? ⇒ Boolean
Check if session has errors.
96 97 98 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 96 def has_errors? @navigation.errors.any? end |
#run ⇒ Hash
Run the interactive review loop.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 52 def run @running = true # Show welcome message show_welcome # Show summary screen puts @formatter.summary_screen(@document, @navigation) # Main interactive loop while @running && @navigation.current show_current_error process_input(get_user_input) end # Show exit message show_exit_summary # Return session summary session_summary end |
#run_batch ⇒ BatchReporter
Run in batch mode (non-interactive).
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 77 def run_batch # Analyze all errors without user interaction errors = @navigation.errors # Apply all high-confidence corrections automatically errors.each do |error| if error.high_confidence? && error.suggestions&.any? @navigation.accept_suggestion(error.recommended_suggestion) end end # Return batch reporter require_relative 'batch_reporter' BatchReporter.new(@document, @navigation, @formatter) end |
#statistics ⇒ Hash
Get session statistics.
103 104 105 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 103 def statistics @navigation.statistics end |