diff options
author | James Wen <jrw2175@columbia.edu> | 2016-01-02 23:27:29 -0500 |
---|---|---|
committer | James Wen <jrw2175@columbia.edu> | 2016-01-02 23:27:29 -0500 |
commit | cb0a52226166a6772642ca8dfbbbd4acee1c8e51 (patch) | |
tree | 803f783b1b0d8d41d5a0455cddc726ff97c78626 /lib/bundler/fetcher.rb | |
parent | 47c1b87d9b02581a99d6195ec76fe97dfd8ff95f (diff) | |
download | bundler-cb0a52226166a6772642ca8dfbbbd4acee1c8e51.tar.gz |
Extract safe const_get logic into `SharedHelpers#const_get_safely`
Diffstat (limited to 'lib/bundler/fetcher.rb')
-rw-r--r-- | lib/bundler/fetcher.rb | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index 7d30506fd6..af190bae21 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -53,15 +53,13 @@ module Bundler # Exceptions classes that should bypass retry attempts. If your password didn't work the # first time, it's not going to the third time. AUTH_ERRORS = [AuthenticationRequiredError, BadAuthenticationError] - NET_ERRORS_TO_ADD_SAFELY = [:HTTPBadGateway, :HTTPBadRequest, :HTTPFailedDependency, - :HTTPForbidden, :HTTPInsufficientStorage, :HTTPMethodNotAllowed, - :HTTPMovedPermanently, :HTTPNoContent, :HTTPNotFound, - :HTTPNotImplemented, :HTTPPreconditionFailed, :HTTPRequestEntityTooLarge, - :HTTPRequestURITooLong, :HTTPUnauthorized, :HTTPUnprocessableEntity, - :HTTPUnsupportedMediaType, :HTTPVersionNotSupported] - NET_ERRORS_TO_ADD_SAFELY.each do |net_error| - AUTH_ERRORS << Net.const_get(net_error) if Net.constants.include? net_error - end + NET_ERRORS = [:HTTPBadGateway, :HTTPBadRequest, :HTTPFailedDependency, + :HTTPForbidden, :HTTPInsufficientStorage, :HTTPMethodNotAllowed, + :HTTPMovedPermanently, :HTTPNoContent, :HTTPNotFound, + :HTTPNotImplemented, :HTTPPreconditionFailed, :HTTPRequestEntityTooLarge, + :HTTPRequestURITooLong, :HTTPUnauthorized, :HTTPUnprocessableEntity, + :HTTPUnsupportedMediaType, :HTTPVersionNotSupported] + AUTH_ERRORS.push(*NET_ERRORS.map {|e| SharedHelpers.const_get_safely(e, Net) }.compact) class << self attr_accessor :disable_endpoint, :api_timeout, :redirect_limit, :max_retries |