diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-05-28 08:45:27 +0200 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-06-11 12:36:19 +0200 |
commit | 7eccba0e520a3d4a82915cac46d0b8c919c0999b (patch) | |
tree | d1f9b3465631749e5ad6ae04ce7e4024b6da125d | |
parent | 1b7e274cbc9e51892e4efc115a97c728e026d966 (diff) | |
download | bundler-7eccba0e520a3d4a82915cac46d0b8c919c0999b.tar.gz |
Use rubygems utility if available
-rw-r--r-- | lib/bundler/fetcher.rb | 2 | ||||
-rw-r--r-- | lib/bundler/fetcher/index.rb | 2 | ||||
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 12 |
3 files changed, 14 insertions, 2 deletions
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index 8084a530d1..8118c2b2e7 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -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) diff --git a/lib/bundler/fetcher/index.rb b/lib/bundler/fetcher/index.rb index d10c21b041..d2ad657fe6 100644 --- a/lib/bundler/fetcher/index.rb +++ b/lib/bundler/fetcher/index.rb @@ -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) diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 9df0897ca2..3e74acf694 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -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 |