lib/autobuild/progress_display.rb in autobuild-1.21.0 vs lib/autobuild/progress_display.rb in autobuild-1.22.0
- old
+ new
@@ -43,11 +43,11 @@
attr_reader :progress_period
# Valid progress modes
#
# @see progress_mode=
- PROGRESS_MODES = %I[single_line newline off]
+ PROGRESS_MODES = %I[single_line newline off].freeze
# Sets how progress messages will be displayed
#
# @param [String] the new mode. Can be either 'single_line', where a
# progress message replaces the last one, 'newline' which displays
@@ -55,11 +55,11 @@
def progress_mode=(mode)
mode = mode.to_sym
unless PROGRESS_MODES.include?(mode)
raise ArgumentError,
"#{mode} is not a valid mode, expected one of "\
- "#{PROGRESS_MODES.join(", ")}"
+ "#{PROGRESS_MODES.join(', ')}"
end
@progress_mode = mode
end
# Return the current display mode
@@ -70,13 +70,11 @@
def silent?
@silent
end
- def silent=(flag)
- @silent = flag
- end
+ attr_writer :silent
def silent
silent = @silent
@silent = true
yield
@@ -154,11 +152,11 @@
changed = current_size != @progress_messages.size
if changed
if message
message(" #{message}")
- # Note: message updates the display already
+ # NOTE: message updates the display already
else
refresh_display
end
true
end
@@ -176,12 +174,10 @@
def refresh_display_under_lock
# Display queued messages
until @message_queue.empty?
message, args, io = @message_queue.pop
- if @progress_mode == :single_line
- io.print @cursor.clear_screen_down
- end
+ io.print @cursor.clear_screen_down if @progress_mode == :single_line
io.puts @color.call(message, *args)
io.flush if @io != io
end