class MinitestBender::Printers::WithProgressBar

Constants

COMPLETE_ICON
ELAPSED_ICON
ETA_ICON
HEAD_ICON
INCOMPLETE_ICON

Attributes

bar[R]
io[R]
total[R]

Public Class Methods

new(io, total) click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 15
def initialize(io, total)
  @io = io
  @total = total
  @bar = new_bar
end

Public Instance Methods

advance() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 37
def advance
  bar.update({ head: head })
  bar.advance(1, { counters_sym => counters })
end
print(string) click to toggle source
print_line(line = '') click to toggle source
print_lines(lines) click to toggle source

Private Instance Methods

bar_format_string() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 56
def bar_format_string
  ":bar #{Colorizer.colorize(':current/:total', :tests)}  :#{counters_sym}  #{Colorizer.colorize(elapsed_icon + ' :elapsed', :time)}   #{Colorizer.colorize(eta_icon + ':eta', :time)}  #{Colorizer.colorize(':percent', :normal, :bold)}"
end
complete_icon() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 78
def complete_icon
  COMPLETE_ICON
end
counters() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 60
def counters
  states.map do |state|
    state.colored_icon_with_count(counters_padding_right)
  end.join('  ')
end
counters_padding_right() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 110
def counters_padding_right
  @counters_padding_right ||= total.to_s.size + 1
end
counters_sym() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 66
def counters_sym
  ('c' * counters_sym_length).to_sym
end
counters_sym_length() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 70
def counters_sym_length
  ( 4 * (total.to_s.size + 1) ) + 6
end
elapsed_icon() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 90
def elapsed_icon
  ELAPSED_ICON
end
eta_icon() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 94
def eta_icon
  ETA_ICON
end
head() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 74
def head
  Colorizer.colorize(head_icon, head_color)
end
head_color() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 98
def head_color
  reverse_states.find { |s| !s.results.empty? }.color
end
head_icon() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 82
def head_icon
  HEAD_ICON
end
incomplete_icon() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 86
def incomplete_icon
  INCOMPLETE_ICON
end
new_bar() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 46
def new_bar
  TTY::ProgressBar.new(bar_format_string, {
    total: total,
    width: [total, TTY::ProgressBar.max_columns].max,
    complete: complete_icon,
    head: head_icon,
    incomplete: incomplete_icon
  })
end
reverse_states() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 106
def reverse_states
  @reverse_states ||= states.reverse
end
states() click to toggle source
# File lib/minitest-bender/printers/with_progress_bar.rb, line 102
def states
  @states ||= MinitestBender.states.values
end