Class: Spellr::Interactive

Inherits:
BaseReporter show all
Defined in:
lib/spellr/interactive.rb

Instance Method Summary collapse

Methods inherited from BaseReporter

#counts, #exit_code, #increment, #initialize, #output, #print, #puts, #warn

Methods included from StringFormat

aqua, bold, color_enabled?, green, normal, pluralize, red

Constructor Details

This class inherits a constructor from Spellr::BaseReporter

Instance Method Details

#call(token) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/spellr/interactive.rb', line 41

def call(token)
  return if attempt_global_replacement(token)
  return if attempt_global_skip(token)

  super

  prompt(token)
end

#finishObject

rubocop:disable Metrics/AbcSize, Metrics/MethodLength



16
17
18
19
20
21
22
23
24
25
# File 'lib/spellr/interactive.rb', line 16

def finish # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  puts "\n"
  puts "#{pluralize 'file', counts[:checked]} checked"
  puts "#{pluralize 'error', total} found"
  if counts[:total_skipped].positive?
    puts "#{pluralize 'error', counts[:total_skipped]} skipped"
  end
  puts "#{pluralize 'error', counts[:total_fixed]} fixed" if counts[:total_fixed].positive?
  puts "#{pluralize 'word', counts[:total_added]} added" if counts[:total_added].positive?
end

#global_replacementsObject



27
28
29
30
31
32
# File 'lib/spellr/interactive.rb', line 27

def global_replacements
  @global_replacements ||= begin
    counts[:global_replacements] = {} unless counts.key?(:global_replacements)
    counts[:global_replacements]
  end
end

#global_skipsObject



34
35
36
37
38
39
# File 'lib/spellr/interactive.rb', line 34

def global_skips
  @global_skips ||= begin
    counts[:global_skips] = [] unless counts.key?(:global_skips)
    counts[:global_skips]
  end
end

#parallel?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/spellr/interactive.rb', line 12

def parallel?
  false
end

#stdin_getchObject



50
51
52
53
54
# File 'lib/spellr/interactive.rb', line 50

def stdin_getch
  choice = output.stdin.getch
  clear_current_line
  choice
end