diff options
author | David Rodriguez <deivid.rodriguez@riseup.net> | 2021-10-20 18:49:34 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-10-25 20:48:50 +0900 |
commit | edc1813190b83169e4cf1ed9cc1419ccb5c3b594 (patch) | |
tree | 3ad0dd99f16c4ab4db57c75144d61d4618b143a9 | |
parent | 13068ebe32a7b8a1a9bd4fc2d5f157880b374e1d (diff) | |
download | ruby-edc1813190b83169e4cf1ed9cc1419ccb5c3b594.tar.gz |
[rubygems/rubygems] Small refactor
Extract final cache path to a variable and pass that to `download_gem`.
It actually fits better the parameters documentation since it's the
final directory where the downloaded gem will be placed.
https://github.com/rubygems/rubygems/commit/1429db6a04
-rw-r--r-- | lib/bundler/source/rubygems.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 28c1ee3c96..dca1d72577 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -460,18 +460,19 @@ module Bundler spec.fetch_platform download_path = requires_sudo? ? Bundler.tmp(spec.full_name) : rubygems_dir + download_cache_path = "#{download_path}/cache" gem_path = "#{rubygems_dir}/cache/#{spec.full_name}.gem" - SharedHelpers.filesystem_access("#{download_path}/cache") do |p| + SharedHelpers.filesystem_access(download_cache_path) do |p| FileUtils.mkdir_p(p) end - download_gem(spec, download_path) + download_gem(spec, download_cache_path) if requires_sudo? SharedHelpers.filesystem_access("#{rubygems_dir}/cache") do |p| Bundler.mkdir_p(p) end - Bundler.sudo "mv #{download_path}/cache/#{spec.full_name}.gem #{gem_path}" + Bundler.sudo "mv #{download_cache_path}/#{spec.full_name}.gem #{gem_path}" end gem_path @@ -503,11 +504,11 @@ module Bundler # @param [Specification] spec # the spec we want to download or retrieve from the cache. # - # @param [String] download_path + # @param [String] download_cache_path # the local directory the .gem will end up in. # - def download_gem(spec, download_path) - local_path = File.join(download_path, "cache/#{spec.full_name}.gem") + def download_gem(spec, download_cache_path) + local_path = File.join(download_cache_path, "#{spec.full_name}.gem") if (cache_path = download_cache_path(spec)) && cache_path.file? SharedHelpers.filesystem_access(local_path) do @@ -516,7 +517,7 @@ module Bundler else uri = spec.remote.uri Bundler.ui.confirm("Fetching #{version_message(spec)}") - rubygems_local_path = Bundler.rubygems.download_gem(spec, uri, download_path) + rubygems_local_path = Bundler.rubygems.download_gem(spec, uri, File.dirname(download_cache_path)) # older rubygems return varying file:// variants depending on version rubygems_local_path = rubygems_local_path.gsub(/\Afile:/, "") unless Bundler.rubygems.provides?(">= 3.2.0.rc.2") |