Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add threaded download reporter

  • Loading branch information...
commit 065dbf65297ac7c3e78c6e325d5f816ead2109e3 1 parent 61775d7
@charliesome authored
Showing with 30 additions and 0 deletions.
  1. +30 −0 lib/rubygems/user_interaction.rb
View
30 lib/rubygems/user_interaction.rb
@@ -566,6 +566,36 @@ def done
end
end
+ class ThreadedDownloadReporter
+ MUTEX = Mutex.new
+
+ attr_reader :file_name
+
+ def initialize(out_stream)
+ @out = out_stream
+ end
+
+ def fetch(file_name, total_bytes)
+ @file_name = file_name
+ locked_puts "Downloading: #{file_name}"
+ end
+
+ def update(bytes)
+ # nah
+ end
+
+ def done
+ locked_puts "Finished: #{file_name}"
+ end
+
+ private
+ def locked_puts(msg)
+ MUTEX.synchronize do
+ @out.puts msg
+ end
+ end
+ end
+
##
# A progress reporter that prints out messages about the current progress.
Please sign in to comment.
Something went wrong with that request. Please try again.