lib/progress.rb in progress-0.1.1.0 vs lib/progress.rb in progress-0.1.1.1
- old
+ new
@@ -129,24 +129,27 @@
@highlight.nil? ? io_tty? : @highlight
end
def print_message
messages = []
+ messages_hl = []
inner = 0
levels.reverse.each do |l|
current = l.to_f(inner)
- messages << "#{l.title}: #{(current == 0 ? '......' : '%5.1f%%' % (current * 100.0))[0, 6]}"
+ value = current == 0 ? '......' : '%5.1f%%' % (current * 100.0)
+ messages << "#{l.title}: #{value}"
+ messages_hl << "#{l.title}: #{value == '100.0' ? value : "\e[1m#{value}\e[0m"}" if highlight?
inner = current
end
message = messages.reverse * ' > '
unless lines?
previous_length = @previous_length || 0
@previous_length = message.length
message = message.ljust(previous_length, ' ') + "\r"
end
- message.gsub!(/\d+\.\d+/){ |s| s == '100.0' ? s : "\e[1m#{s}\e[0m" } if highlight?
+ message = messages_hl.reverse * ' > ' if highlight?
lines? ? io.puts(message) : io.print(message)
end
end
end