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

ruby-changes:72139

From: David <ko1@a...>
Date: Sat, 11 Jun 2022 18:43:57 +0900 (JST)
Subject: [ruby-changes:72139] 22c97ab8ae (master): [rubygems/rubygems] Refactor some more duplicated logic

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

From 22c97ab8ae2b13b3048d7edee223272640dbda59 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Wed, 6 Apr 2022 10:32:01 +0200
Subject: [rubygems/rubygems] Refactor some more duplicated logic

https://github.com/rubygems/rubygems/commit/9bd389e1b6
---
 lib/bundler/source/rubygems.rb | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index d166410a9d..55fde3ad3a 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -361,10 +361,14 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/rubygems.rb#L361
         global_cache_path = download_cache_path(spec)
         @caches << global_cache_path if global_cache_path
 
-        possibilities = @caches.map {|p| "#{p}/#{spec.file_name}" }
+        possibilities = @caches.map {|p| package_path(p, spec) }
         possibilities.find {|p| File.exist?(p) }
       end
 
+      def package_path(cache_path, spec)
+        "#{cache_path}/#{spec.file_name}"
+      end
+
       def normalize_uri(uri)
         uri = uri.to_s
         uri = "#{uri}/" unless uri =~ %r{/$}
@@ -459,7 +463,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/rubygems.rb#L463
         spec.fetch_platform
 
         cache_path = download_cache_path(spec) || default_cache_path_for(rubygems_dir)
-        gem_path = "#{cache_path}/#{spec.file_name}"
+        gem_path = package_path(cache_path, spec)
         return gem_path if File.exist?(gem_path)
 
         if requires_sudo?
@@ -478,7 +482,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/rubygems.rb#L482
           SharedHelpers.filesystem_access(cache_path) do |p|
             Bundler.mkdir_p(p)
           end
-          Bundler.sudo "mv #{download_cache_path}/#{spec.file_name} #{gem_path}"
+          Bundler.sudo "mv #{package_path(download_cache_path, spec)} #{gem_path}"
         end
 
         gem_path
-- 
cgit v1.2.1


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

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