summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-10-23 17:45:31 +0200
committergit <svn-admin@ruby-lang.org>2022-01-15 00:00:10 +0900
commit044b0ae8e054b9959dc48bd5e663cbf2dea653a4 (patch)
tree5865d1cb5f499d31d6ac7f65b2633c739f01c5ed /lib
parent3006451f6511b6594a24a9046f390c3bec6a7465 (diff)
[rubygems/rubygems] Extract a bit of common logic to methods
https://github.com/rubygems/rubygems/commit/9a1b891435
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems/installer.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 760f8f90f7..0224b91898 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -585,7 +585,7 @@ class Gem::Installer
#
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
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
# 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
Gem::Command.build_args
end
end
+
+ def rb_config
+ RbConfig::CONFIG
+ end
+
+ def ruby_install_name
+ rb_config["ruby_install_name"]
+ end
end