1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[bundler/bundler] Use rubygems utility if available

https://github.com/bundler/bundler/commit/7eccba0e52
This commit is contained in:
David Rodríguez 2019-05-28 08:45:27 +02:00 committed by Hiroshi SHIBATA
parent e111f38f34
commit 81779e2246
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2
3 changed files with 14 additions and 2 deletions

View file

@ -99,7 +99,7 @@ module Bundler
uri = URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
if uri.scheme == "file"
path = Gem.win_platform? ? uri.path[1..-1] : uri.path
path = Bundler.rubygems.correct_for_windows_path(uri.path)
Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
elsif cached_spec_path = gemspec_cached_path(spec_file_name)
Bundler.load_gemspec(cached_spec_path)

View file

@ -30,7 +30,7 @@ module Bundler
uri = URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
if uri.scheme == "file"
path = Gem.win_platform? ? uri.path[1..-1] : uri.path
path = Bundler.rubygems.correct_for_windows_path(uri.path)
Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
elsif cached_spec_path = gemspec_cached_path(spec_file_name)
Bundler.load_gemspec(cached_spec_path)

View file

@ -146,6 +146,18 @@ module Bundler
end
end
def correct_for_windows_path(path)
require "rubygems/util"
if Gem::Util.respond_to?(:correct_for_windows_path)
Gem::Util.correct_for_windows_path(path)
elsif path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":"
path[1..-1]
else
path
end
end
def sources=(val)
# Gem.configuration creates a new Gem::ConfigFile, which by default will read ~/.gemrc
# If that file exists, its settings (including sources) will overwrite the values we