summaryrefslogtreecommitdiff
path: root/lib/bundler/shared_helpers.rb
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-01-03 14:59:22 +0900
committerHomu <homu@barosl.com>2016-01-03 14:59:22 +0900
commitc3684b0a43edd26841b84bbcc2912a3cee8b21da (patch)
tree7dd98744325758e936e498d688aaba23ea31a435 /lib/bundler/shared_helpers.rb
parent4a392031adea279a598426860a2e3fca9d27f6ec (diff)
parenta5da09c97c6e7e2be482809dbf0c019178d34176 (diff)
downloadbundler-c3684b0a43edd26841b84bbcc2912a3cee8b21da.tar.gz
Auto merge of #4195 - RochesterinNYC:add-net-http-errors-safely, r=segiddins
Add `Net#HTTP--` errors safely (only if in version of ruby stdlib) Continuation of #4154. Some errors in the ruby `Net` module that we might not want to retry on were added in later Ruby versions of the stdlib. This PR allows us to preserve backwards compatibility while adding new errors.
Diffstat (limited to 'lib/bundler/shared_helpers.rb')
-rw-r--r--lib/bundler/shared_helpers.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 7ca55a9ee0..d0c3f430aa 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -120,6 +120,13 @@ module Bundler
raise TemporaryResourceError.new(path, action)
end
+ def const_get_safely(constant_name, namespace)
+ const_in_namespace = namespace.constants.include?(constant_name.to_s) ||
+ namespace.constants.include?(constant_name.to_sym)
+ return nil unless const_in_namespace
+ namespace.const_get(constant_name)
+ end
+
private
def find_gemfile