Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::Installer#app_script_text
app_script_text(bin_file_name)
lib/rubygems/installer.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/installer.rb, line 746
def app_script_text(bin_file_name)
# NOTE: that the `load` lines cannot be indented, as old RG versions match
# against the beginning of the line
escaped_bin_file_name = bin_file_name.gsub(/[\\']/) {|c| "\\#{c}" }
<<~TEXT
#{shebang bin_file_name}
#
# This file was generated by RubyGems.
#
# The application '#{spec.name}' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
#{gemdeps_load(spec.name)}
version = "#{Gem::Requirement.default_prerelease}"
str = ARGV.first
if str
str = str.b[/\\A_(.*)_\\z/, 1]
if str and Gem::Version.correct?(str)
#{explicit_version_requirement(spec.name)}
ARGV.shift
end
end
if Gem.respond_to?(:activate_and_load_bin_path)
Gem.activate_and_load_bin_path('#{spec.name}', '#{escaped_bin_file_name}', version)
else
load Gem.activate_bin_path('#{spec.name}', '#{escaped_bin_file_name}', version)
end
TEXT
end
Return the text for an application file.
See also
.new
#assign_content_address
.for_spec
#bash_prolog_script
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0