Permalink
Browse files

delete VerboseDownloadReporter

  • Loading branch information...
1 parent 07d2d84 commit a0dfd0c478eb6f2c53df3a7f7bd3f9f11ee1805e @charliesome committed Jan 3, 2014
Showing with 0 additions and 79 deletions.
  1. +0 −79 lib/rubygems/user_interaction.rb
@@ -595,85 +595,6 @@ def locked_puts(msg)
end
end
end
-
- ##
- # A progress reporter that prints out messages about the current progress.
-
- class VerboseDownloadReporter
-
- ##
- # The current file name being displayed
-
- attr_reader :file_name
-
- ##
- # The total bytes in the file
-
- attr_reader :total_bytes
-
- ##
- # The current progress (0 to 100)
-
- attr_reader :progress
-
- ##
- # Creates a new verbose download reporter that will display on
- # +out_stream+. The other arguments are ignored.
-
- def initialize(out_stream, *args)
- @out = out_stream
- @progress = 0
- end
-
- ##
- # Tells the download reporter that the +file_name+ is being fetched and
- # contains +total_bytes+.
-
- def fetch(file_name, total_bytes)
- @file_name = file_name
- @total_bytes = total_bytes.to_i
- @units = @total_bytes.zero? ? 'B' : '%'
-
- update_display(false)
- end
-
- ##
- # Updates the verbose download reporter for the given number of +bytes+.
-
- def update(bytes)
- new_progress = if @units == 'B' then
- bytes
- else
- ((bytes.to_f * 100) / total_bytes.to_f).ceil
- end
-
- return if new_progress == @progress
-
- @progress = new_progress
- update_display
- end
-
- ##
- # Indicates the download is complete.
-
- def done
- @progress = 100 if @units == '%'
- update_display(true, true)
- end
-
- private
-
- def update_display(show_progress = true, new_line = false) # :nodoc:
- return unless @out.tty?
-
- if show_progress then
- @out.print "\rFetching: %s (%3d%s)" % [@file_name, @progress, @units]
- else
- @out.print "Fetching: %s" % @file_name
- end
- @out.puts if new_line
- end
- end
end
##

0 comments on commit a0dfd0c

Please sign in to comment.