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.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 25 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.
18 19 20 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 18 def analyzer @analyzer end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
18 19 20 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 18 def document @document end |
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
18 19 20 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 18 def formatter @formatter end |
#navigation ⇒ Object (readonly)
Returns the value of attribute navigation.
18 19 20 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 18 def @navigation end |
Instance Method Details
#has_errors? ⇒ Boolean
Check if session has errors.
91 92 93 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 91 def has_errors? @navigation.errors.any? end |
#run ⇒ Hash
Run the interactive review loop.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 48 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).
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 73 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 BatchReporter.new(@document, @navigation, @formatter) end |
#statistics ⇒ Hash
Get session statistics.
98 99 100 |
# File 'lib/kotoshu/cli/interactive_reviewer.rb', line 98 def statistics @navigation.statistics end |