lib/autobuild/reporting.rb in autobuild-1.13.0 vs lib/autobuild/reporting.rb in autobuild-1.14.0
- old
+ new
@@ -50,19 +50,14 @@
io.puts msg
end
return
end
- size =
- if @last_progress_msg then @last_progress_msg.size
- else 0
- end
-
if !silent?
- io.puts "\r#{msg}#{" " * [size - msg.size, 0].max}"
+ io.puts "#{clear_line}#{msg}"
if @last_progress_msg
- print "#{@last_progress_msg}"
+ io.print @last_progress_msg
end
end
end
class << self
@@ -84,10 +79,14 @@
# key
def self.has_progress_for?(key)
progress_messages.any? { |msg_key, _| msg_key == key }
end
+ def self.clear_line
+ "\e[2K\e[1G"
+ end
+
def self.progress_start(key, *args)
if args.last.kind_of?(Hash)
options = Kernel.validate_options args.pop, :done_message => nil
else
options = Hash.new
@@ -224,27 +223,20 @@
result.join(" | ")
end
def self.display_progress
msg = format_progress_message(progress_messages.map(&:last))
- last_msg_length =
- if @last_progress_msg then @last_progress_msg.length
- else 0
- end
if msg.empty?
- blank = " " * last_msg_length
@last_progress_msg = nil
else
msg = " #{msg}"
- blank = " " * [last_msg_length - msg.length, 0].max
@last_progress_msg = msg
end
if !silent?
if Autobuild.progress_display_enabled?
- print "\r#{msg}#{blank}"
- print "\r#{msg}"
+ print "#{clear_line}#{msg}"
elsif @last_progress_msg
puts msg
end
end
end