[前][次][番号順一覧][スレッド一覧]

ruby-changes:69422

From: David <ko1@a...>
Date: Mon, 25 Oct 2021 20:55:07 +0900 (JST)
Subject: [ruby-changes:69422] edc1813190 (master): [rubygems/rubygems] Small refactor

https://git.ruby-lang.org/ruby.git/commit/?id=edc1813190

From edc1813190b83169e4cf1ed9cc1419ccb5c3b594 Mon Sep 17 00:00:00 2001
From: David Rodriguez <deivid.rodriguez@r...>
Date: Wed, 20 Oct 2021 18:49:34 +0200
Subject: [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
---
 lib/bundler/source/rubygems.rb | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 28c1ee3c968..dca1d725771 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -460,18 +460,19 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/rubygems.rb#L460
         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 https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/rubygems.rb#L504
       # @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 https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/rubygems.rb#L517
         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")
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]