Class: MinitestBender::Printers::WithProgressBar

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest-bender/printers/with_progress_bar.rb

Constant Summary collapse

COMPLETE_ICON =
' '
HEAD_ICON =
'ᗧ'
INCOMPLETE_ICON =
'•'
ELAPSED_ICON =
'⏱'
ETA_ICON =
'⌛'

Instance Method Summary collapse

Constructor Details

#initialize(io, total) ⇒ WithProgressBar

Returns a new instance of WithProgressBar.



15
16
17
18
19
# File 'lib/minitest-bender/printers/with_progress_bar.rb', line 15

def initialize(io, total)
  @io = io
  @total = total
  @bar = new_bar
end

Instance Method Details

#advanceObject



37
38
39
40
# File 'lib/minitest-bender/printers/with_progress_bar.rb', line 37

def advance
  bar.update({ head: head })
  bar.advance(1, { counters_sym => counters })
end


21
22
23
# File 'lib/minitest-bender/printers/with_progress_bar.rb', line 21

def print(string)
  io.print(string)
end


25
26
27
28
29
30
31
# File 'lib/minitest-bender/printers/with_progress_bar.rb', line 25

def print_line(line = '')
  if io.tty?
    bar.log(line)
  else
    io.puts(line)
  end
end


33
34
35
# File 'lib/minitest-bender/printers/with_progress_bar.rb', line 33

def print_lines(lines)
  lines.each { |line| print_line(line) }
end