Class: Gem::StreamUI::ThreadedDownloadReporter
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rubygems/user_interaction.rb |
Overview
A progress reporter that behaves nicely with threaded downloading.
Constant Summary
-
MUTEX =
# File 'lib/rubygems/user_interaction.rb', line 565Mutex.new
Class Method Summary
-
.new(out_stream, *args) ⇒ ThreadedDownloadReporter
constructor
Creates a new threaded download reporter that will display on
out_stream
.
Instance Attribute Summary
-
#file_name
readonly
The current file name being displayed.
Instance Method Summary
-
#done
Indicates the download is complete.
-
#fetch(file_name, *args)
Tells the download reporter that the #file_name is being fetched.
-
#update(bytes)
Updates the threaded download reporter for the given number of
bytes
. - #locked_puts(message) private
Constructor Details
.new(out_stream, *args) ⇒ ThreadedDownloadReporter
Creates a new threaded download reporter that will display on out_stream
. The other arguments are ignored.
# File 'lib/rubygems/user_interaction.rb', line 576
def initialize(out_stream, *args) @file_name = nil @out = out_stream end
Instance Attribute Details
#file_name (readonly)
The current file name being displayed
# File 'lib/rubygems/user_interaction.rb', line 570
attr_reader :file_name
Instance Method Details
#done
Indicates the download is complete.
# File 'lib/rubygems/user_interaction.rb', line 602
def done # Do nothing. end
#fetch(file_name, *args)
Tells the download reporter that the #file_name is being fetched. The other arguments are ignored.
# File 'lib/rubygems/user_interaction.rb', line 585
def fetch(file_name, *args) if @file_name.nil? @file_name = file_name locked_puts "Fetching #{@file_name}" end end
#locked_puts(message) (private)
[ GitHub ]# File 'lib/rubygems/user_interaction.rb', line 608
def locked_puts( ) MUTEX.synchronize do @out.puts end end
#update(bytes)
Updates the threaded download reporter for the given number of bytes
.
# File 'lib/rubygems/user_interaction.rb', line 595
def update(bytes) # Do nothing. end