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

ruby-changes:70868

From: David <ko1@a...>
Date: Sat, 15 Jan 2022 00:00:25 +0900 (JST)
Subject: [ruby-changes:70868] 044b0ae8e0 (master): [rubygems/rubygems] Extract a bit of common logic to methods

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

From 044b0ae8e054b9959dc48bd5e663cbf2dea653a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Wed, 23 Oct 2019 17:45:31 +0200
Subject: [rubygems/rubygems] Extract a bit of common logic to methods

https://github.com/rubygems/rubygems/commit/9a1b891435
---
 lib/rubygems/installer.rb | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 760f8f90f76..0224b918984 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -585,7 +585,7 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L585
   #
 
   def shebang(bin_file_name)
-    ruby_name = RbConfig::CONFIG['ruby_install_name'] if @env_shebang
+    ruby_name = ruby_install_name if @env_shebang
     path = File.join gem_dir, spec.bindir, bin_file_name
     first_line = File.open(path, "rb") {|file| file.gets } || ""
 
@@ -598,7 +598,7 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L598
 
     if which = Gem.configuration[:custom_shebang]
       # replace bin_file_name with "ruby" to avoid endless loops
-      which = which.gsub(/ #{bin_file_name}$/," #{RbConfig::CONFIG['ruby_install_name']}")
+      which = which.gsub(/ #{bin_file_name}$/," #{ruby_install_name}")
 
       which = which.gsub(/\$(\w+)/) do
         case $1
@@ -805,7 +805,6 @@ TEXT https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L805
   # return the stub script text used to launch the true Ruby script
 
   def windows_stub_script(bindir, bin_file_name)
-    rb_config = RbConfig::CONFIG
     rb_topdir = RbConfig::TOPDIR || File.dirname(rb_config["bindir"])
 
     # get ruby executable file name from RbConfig
@@ -973,4 +972,12 @@ TEXT https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L972
                       Gem::Command.build_args
                     end
   end
+
+  def rb_config
+    RbConfig::CONFIG
+  end
+
+  def ruby_install_name
+    rb_config["ruby_install_name"]
+  end
 end
-- 
cgit v1.2.1


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

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