Permalink
Browse files

add concurrent_downloads config option

  • Loading branch information...
1 parent a0dfd0c commit 8f5e0084736f8da2001381e0f7bc48908a6f234c @charliesome committed Jan 3, 2014
Showing with 15 additions and 0 deletions.
  1. +15 −0 lib/rubygems/config_file.rb
View
15 lib/rubygems/config_file.rb
@@ -26,6 +26,7 @@
# +:backtrace+:: See #backtrace
# +:sources+:: Sets Gem::sources
# +:verbose+:: See #verbose
+# +:concurrent_downloads+:: See #concurrent_downloads
#
# gemrc files may exist in various locations and are read and merged in
# the following order:
@@ -42,6 +43,7 @@ class Gem::ConfigFile
DEFAULT_BULK_THRESHOLD = 1000
DEFAULT_VERBOSITY = true
DEFAULT_UPDATE_SOURCES = true
+ DEFAULT_CONCURRENT_DOWNLOADS = 8
##
# For Ruby packagers to set configuration defaults. Set in
@@ -123,6 +125,11 @@ class Gem::ConfigFile
attr_accessor :verbose
##
+ # Number of gem downloads that should be performed concurrently
+
+ attr_accessor :concurrent_downloads
+
+ ##
# True if we want to update the SourceInfoCache every time, false otherwise
attr_accessor :update_sources
@@ -190,6 +197,7 @@ def initialize(args)
@bulk_threshold = DEFAULT_BULK_THRESHOLD
@verbose = DEFAULT_VERBOSITY
@update_sources = DEFAULT_UPDATE_SOURCES
+ @concurrent_downloads = DEFAULT_CONCURRENT_DOWNLOADS
operating_system_config = Marshal.load Marshal.dump(OPERATING_SYSTEM_DEFAULTS)
platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS)
@@ -212,6 +220,7 @@ def initialize(args)
@path = @hash[:gempath] if @hash.key? :gempath
@update_sources = @hash[:update_sources] if @hash.key? :update_sources
@verbose = @hash[:verbose] if @hash.key? :verbose
+ @concurrent_downloads = @hash[:concurrent_downloads] if @hash.key? :concurrent_downloads
@disable_default_gem_server = @hash[:disable_default_gem_server] if @hash.key? :disable_default_gem_server
@ssl_verify_mode = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
@@ -427,6 +436,12 @@ def to_yaml # :nodoc:
DEFAULT_VERBOSITY
end
+ yaml_hash[:concurrent_downloads] = if @hash.key?(:concurrent_downloads)
+ @hash[:concurrent_downloads]
+ else
+ DEFAULT_CONCURRENT_DOWNLOADS
+ end
+
keys = yaml_hash.keys.map { |key| key.to_s }
keys << 'debug'
re = Regexp.union(*keys)

0 comments on commit 8f5e008

Please sign in to comment.