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

ruby-changes:69591

From: David <ko1@a...>
Date: Fri, 5 Nov 2021 07:23:50 +0900 (JST)
Subject: [ruby-changes:69591] 70cbca48b8 (master): [rubygems/rubygems] Refactor `--destdir` handling

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

From 70cbca48b8df97ba75e665e147f6ad8bb39e752d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Thu, 4 Nov 2021 22:04:26 +0100
Subject: [rubygems/rubygems] Refactor `--destdir` handling

https://github.com/rubygems/rubygems/commit/8aab3d11b0
---
 lib/rubygems/commands/setup_command.rb | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index 00953a8f4b1..98b4b162bc8 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -152,8 +152,7 @@ By default, this RubyGems will install gem as: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L152
     install_destdir = options[:destdir]
 
     unless install_destdir.empty?
-      ENV['GEM_HOME'] ||= File.join(install_destdir,
-                                    Gem.default_dir.gsub(/^[a-zA-Z]:/, ''))
+      ENV['GEM_HOME'] ||= prepend_destdir(Gem.default_dir)
     end
 
     check_ruby_version
@@ -166,8 +165,8 @@ By default, this RubyGems will install gem as: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L165
     end
     extend MakeDirs
 
-    lib_dir, bin_dir = make_destination_dirs install_destdir
-    man_dir = generate_default_man_dir install_destdir
+    lib_dir, bin_dir = make_destination_dirs
+    man_dir = generate_default_man_dir
 
     install_lib lib_dir
 
@@ -424,11 +423,11 @@ By default, this RubyGems will install gem as: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L423
     say "Bundler #{bundler_spec.version} installed"
   end
 
-  def make_destination_dirs(install_destdir)
+  def make_destination_dirs
     lib_dir, bin_dir = Gem.default_rubygems_dirs
 
     unless lib_dir
-      lib_dir, bin_dir = generate_default_dirs(install_destdir)
+      lib_dir, bin_dir = generate_default_dirs
     end
 
     mkdir_p lib_dir, :mode => 0755
@@ -437,7 +436,8 @@ By default, this RubyGems will install gem as: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L436
     return lib_dir, bin_dir
   end
 
-  def generate_default_man_dir(install_destdir)
+  def generate_default_man_dir
+    install_destdir = options[:destdir]
     prefix = options[:prefix]
 
     if prefix.empty?
@@ -448,13 +448,14 @@ By default, this RubyGems will install gem as: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L448
     end
 
     unless install_destdir.empty?
-      man_dir = File.join install_destdir, man_dir.gsub(/^[a-zA-Z]:/, '')
+      man_dir = prepend_destdir(man_dir)
     end
 
     man_dir
   end
 
-  def generate_default_dirs(install_destdir)
+  def generate_default_dirs
+    install_destdir = options[:destdir]
     prefix = options[:prefix]
     site_or_vendor = options[:site_or_vendor]
 
@@ -467,8 +468,8 @@ By default, this RubyGems will install gem as: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L468
     end
 
     unless install_destdir.empty?
-      lib_dir = File.join install_destdir, lib_dir.gsub(/^[a-zA-Z]:/, '')
-      bin_dir = File.join install_destdir, bin_dir.gsub(/^[a-zA-Z]:/, '')
+      lib_dir = prepend_destdir(lib_dir)
+      bin_dir = prepend_destdir(bin_dir)
     end
 
     [lib_dir, bin_dir]
@@ -617,6 +618,10 @@ abort "#{deprecation_message}" https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L618
 
   private
 
+  def prepend_destdir(path)
+    File.join(options[:destdir], path.gsub(/^[a-zA-Z]:/, ''))
+  end
+
   def install_file_list(files, dest_dir)
     files.each do |file|
       install_file file, dest_dir
-- 
cgit v1.2.1


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

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