Class: Forspell::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/forspell/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(files:, speller:, reporter:) ⇒ Runner

Returns a new instance of Runner.



6
7
8
9
10
# File 'lib/forspell/runner.rb', line 6

def initialize(files:, speller:, reporter:)
  @files = files
  @speller = speller
  @reporter = reporter
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/forspell/runner.rb', line 12

def call
  increment = (@files.size / 100.0).ceil
  total = @files.size <= 100 ? @files.size : 100
  @reporter.progress_bar = ProgressBar.create(total: total, output: $stderr)

  @files.each_with_index do |path, index|
    process_file path
    @reporter.progress_bar.increment if (index + 1) % increment == 0
  end

  @reporter.report

  self
end