diff options
| author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2025-07-09 18:34:20 +0200 |
|---|---|---|
| committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2025-07-14 11:52:13 +0900 |
| commit | 15751af90b649a15c461e981daece58ce1ceb9ec (patch) | |
| tree | fcc349bf9da09c2df72e32679606015c07ee2651 | |
| parent | f1cbd58acca3547d802c914b9a6509fc79b15f93 (diff) | |
[rubygems/rubygems] Improve some heredoc indentations
https://github.com/rubygems/rubygems/commit/6ee3a33048
| -rw-r--r-- | lib/rubygems/installer.rb | 76 | ||||
| -rw-r--r-- | test/rubygems/test_gem_installer.rb | 78 |
2 files changed, 77 insertions, 77 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 7a80b55f8b..b659180a54 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -749,49 +749,49 @@ class Gem::Installer 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 - <<-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 + <<~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 -load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version) -TEXT + load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version) + TEXT end def gemdeps_load(name) return "" if name == "bundler" - <<-TEXT + <<~TEXT -Gem.use_gemdeps -TEXT + Gem.use_gemdeps + TEXT end def explicit_version_requirement(name) code = "version = str" return code unless name == "bundler" - code += <<-TEXT + code += <<~TEXT - ENV['BUNDLER_VERSION'] = str -TEXT + ENV['BUNDLER_VERSION'] = str + TEXT end ## @@ -806,9 +806,9 @@ TEXT if File.exist?(File.join(bindir, ruby_exe)) # stub & ruby.exe within same folder. Portable - <<-TEXT -@ECHO OFF -@"%~dp0#{ruby_exe}" "%~dpn0" %* + <<~TEXT + @ECHO OFF + @"%~dp0#{ruby_exe}" "%~dpn0" %* TEXT elsif bindir.downcase.start_with? rb_topdir.downcase # stub within ruby folder, but not standard bin. Portable @@ -816,16 +816,16 @@ TEXT from = Pathname.new bindir to = Pathname.new "#{rb_topdir}/bin" rel = to.relative_path_from from - <<-TEXT -@ECHO OFF -@"%~dp0#{rel}/#{ruby_exe}" "%~dpn0" %* + <<~TEXT + @ECHO OFF + @"%~dp0#{rel}/#{ruby_exe}" "%~dpn0" %* TEXT else # outside ruby folder, maybe -user-install or bundler. Portable, but ruby # is dependent on PATH - <<-TEXT -@ECHO OFF -@#{ruby_exe} "%~dpn0" %* + <<~TEXT + @ECHO OFF + @#{ruby_exe} "%~dpn0" %* TEXT end end diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 1bb5371368..fb5e77f358 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -24,31 +24,31 @@ class TestGemInstaller < Gem::InstallerTestCase util_make_exec @spec, "" - expected = <<-EOF -#!#{Gem.ruby} -# -# This file was generated by RubyGems. -# -# The application 'a' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require 'rubygems' - -Gem.use_gemdeps - -version = \">= 0.a\" - -str = ARGV.first -if str - str = str.b[/\\A_(.*)_\\z/, 1] - if str and Gem::Version.correct?(str) - version = str - ARGV.shift - end -end + expected = <<~EOF + #!#{Gem.ruby} + # + # This file was generated by RubyGems. + # + # The application 'a' is installed as part of a gem, and + # this file is here to facilitate running it. + # + + require 'rubygems' + + Gem.use_gemdeps + + version = \">= 0.a\" + + str = ARGV.first + if str + str = str.b[/\\A_(.*)_\\z/, 1] + if str and Gem::Version.correct?(str) + version = str + ARGV.shift + end + end -load Gem.activate_bin_path('a', 'executable', version) + load Gem.activate_bin_path('a', 'executable', version) EOF wrapper = installer.app_script_text "executable" @@ -116,12 +116,12 @@ load Gem.activate_bin_path('a', 'executable', version) end File.open File.join(util_inst_bindir, "executable"), "w" do |io| - io.write <<-EXEC -#!/usr/local/bin/ruby -# -# This file was generated by RubyGems + io.write <<~EXEC + #!/usr/local/bin/ruby + # + # This file was generated by RubyGems -gem 'other', version + gem 'other', version EXEC end @@ -864,11 +864,11 @@ gem 'other', version spec_version = spec.version plugin_path = File.join("lib", "rubygems_plugin.rb") write_file File.join(@tempdir, plugin_path) do |io| - io.write <<-PLUGIN -#{self.class}.plugin_loaded = true -Gem.post_install do - #{self.class}.post_install_is_called = true -end + io.write <<~PLUGIN + #{self.class}.plugin_loaded = true + Gem.post_install do + #{self.class}.post_install_is_called = true + end PLUGIN end spec.files += [plugin_path] @@ -1552,7 +1552,7 @@ end @spec = setup_base_spec @spec.extensions << "extconf.rb" write_dummy_extconf @spec.name do |io| - io.write <<-RUBY + io.write <<~RUBY CONFIG['CC'] = '$(TOUCH) $@ ||' CONFIG['LDSHARED'] = '$(TOUCH) $@ ||' @@ -1564,7 +1564,7 @@ end write_file File.join(@tempdir, "depend") write_file File.join(@tempdir, "a.c") do |io| - io.write <<-C + io.write <<~C #include <ruby.h> void Init_a() { } C @@ -1601,7 +1601,7 @@ end rb = File.join("lib", "#{@spec.name}.rb") @spec.files += [rb] write_file File.join(@tempdir, rb) do |io| - io.write <<-RUBY + io.write <<~RUBY # #{@spec.name}.rb RUBY end @@ -1610,7 +1610,7 @@ end rb2 = File.join("lib", @spec.name, "#{@spec.name}.rb") @spec.files << rb2 write_file File.join(@tempdir, rb2) do |io| - io.write <<-RUBY + io.write <<~RUBY # #{@spec.name}/#{@spec.name}.rb RUBY end @@ -1637,7 +1637,7 @@ end @spec.extensions << "extconf.rb" write_dummy_extconf @spec.name do |io| - io.write <<-RUBY + io.write <<~RUBY CONFIG['CC'] = '$(TOUCH) $@ ||' CONFIG['LDSHARED'] = '$(TOUCH) $@ ||' |
