Skip to content

Instantly share code, notes, and snippets.

@luislavena
Created September 28, 2010 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luislavena/600349 to your computer and use it in GitHub Desktop.
Save luislavena/600349 to your computer and use it in GitHub Desktop.
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index 626f93d..3dfc2ca 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -341,7 +341,26 @@ class Gem::RemoteFetcher
say "#{request.method} #{uri}" if
Gem.configuration.really_verbose
- response = connection.request request
+
+ file_name = File.basename(uri.path)
+ if file_name =~ /\.gem$/
+ response = connection.request request do |incomplete_response|
+ if Net::HTTPOK === incomplete_response
+ progress, total = 0, incomplete_response.content_length
+ data = ''
+ incomplete_response.read_body do |segment|
+ data << segment
+ progress += segment.length
+ print "\r%s [%d%%]" % [file_name, (progress * 100) / total]
+ end
+ print "\r#{' ' * (file_name.length + 7)}\r"
+ incomplete_response.body = data
+ end
+ end
+ else
+ response = connection.request request
+ end
+
say "#{response.code} #{response.message}" if
Gem.configuration.really_verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment