aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/user_interaction.rb
diff options
context:
space:
mode:
authorryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-28 23:46:47 +0000
committerryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-01-28 23:46:47 +0000
commit934f537b458778f4786716c95b73fc72bc1ce256 (patch)
tree6abdecd9956995a7f82c9f969c80657b4301f6bd /lib/rubygems/user_interaction.rb
parentb511e1bfbe649b938e317e00ad1795f1b9623758 (diff)
downloadruby-934f537b458778f4786716c95b73fc72bc1ce256.tar.gz
Import rubygems 1.5.0 (release candidate @ 09893d9)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/user_interaction.rb')
-rw-r--r--lib/rubygems/user_interaction.rb23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/rubygems/user_interaction.rb b/lib/rubygems/user_interaction.rb
index 06b847cf41..9822a23c35 100644
--- a/lib/rubygems/user_interaction.rb
+++ b/lib/rubygems/user_interaction.rb
@@ -72,7 +72,7 @@ module Gem::DefaultUserInteraction
end
##
-# Make the default UI accessable without the "ui." prefix. Classes
+# Make the default UI accessible without the "ui." prefix. Classes
# including this module may use the interaction methods on the default UI
# directly. Classes may also reference the ui and ui= methods.
#
@@ -224,7 +224,7 @@ class Gem::StreamUI
result
end
- if RUBY_VERSION >= "1.9" then
+ if RUBY_VERSION > '1.9.2' then
##
# Ask for a password. Does not echo response to terminal.
@@ -477,12 +477,20 @@ class Gem::StreamUI
end
def fetch(file_name, total_bytes)
- @file_name, @total_bytes = file_name, total_bytes
+ @file_name = file_name
+ @total_bytes = total_bytes.to_i
+ @units = @total_bytes.zero? ? 'B' : '%'
+
update_display(false)
end
def update(bytes)
- new_progress = ((bytes.to_f * 100) / total_bytes.to_f).ceil
+ 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
@@ -490,7 +498,7 @@ class Gem::StreamUI
end
def done
- @progress = 100
+ @progress = 100 if @units == '%'
update_display(true, true)
end
@@ -498,8 +506,9 @@ class Gem::StreamUI
def update_display(show_progress = true, new_line = false)
return unless @out.tty?
- if show_progress
- @out.print "\rFetching: %s (%3d%%)" % [@file_name, @progress]
+
+ if show_progress then
+ @out.print "\rFetching: %s (%3d%s)" % [@file_name, @progress, @units]
else
@out.print "Fetching: %s" % @file_name
end