Progress bar base class
To define new progress bar you can inherit from this class and implement finite_template and infinite_template methods. Also you may find useful to change more methods like done_message or print_error
# File lib/kafo/progress_bar.rb, line 11 def initialize @lines = 0 @all_lines = 0 @total = :unknown @bar = PowerBar.new @bar.settings.tty.infinite.template.main = infinite_template @bar.settings.tty.finite.template.main = finite_template @bar.settings.tty.finite.template.padchar = ' ' @bar.settings.tty.finite.template.barchar = '.' @bar.settings.tty.finite.output = Proc.new { |s| $stderr.print s } end
# File lib/kafo/progress_bar.rb, line 36 def close @bar.show({ :msg => done_message, :done => @total == :unknown ? @bar.done + 1 : @total, :total => @total }, true) @bar.close end
# File lib/kafo/progress_bar.rb, line 43 def print(line) @bar.print line end
# File lib/kafo/progress_bar.rb, line 47 def print_error(line) print line end
# File lib/kafo/progress_bar.rb, line 23 def update(line) @total = $1.to_i if line =~ /\w*START (\d+)/ @lines += 1 if line.include?('RESOURCE') && @lines < @total - 1 @all_lines += 1 # we print every 20th line during installation preparing otherwise we update every line if @all_lines % 20 == 0 || @total != :unknown @bar.show({ :msg => format(line), :done => @lines, :total => @total }) end end