Skip to content

Commit 15751af

Browse files
deivid-rodriguezhsbt
authored andcommitted
[rubygems/rubygems] Improve some heredoc indentations
ruby/rubygems@6ee3a33048
1 parent f1cbd58 commit 15751af

File tree

2 files changed

+77
-77
lines changed

2 files changed

+77
-77
lines changed

lib/rubygems/installer.rb

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -749,49 +749,49 @@ def verify_spec
749749
def app_script_text(bin_file_name)
750750
# NOTE: that the `load` lines cannot be indented, as old RG versions match
751751
# against the beginning of the line
752-
<<-TEXT
753-
#{shebang bin_file_name}
754-
#
755-
# This file was generated by RubyGems.
756-
#
757-
# The application '#{spec.name}' is installed as part of a gem, and
758-
# this file is here to facilitate running it.
759-
#
760-
761-
require 'rubygems'
762-
#{gemdeps_load(spec.name)}
763-
version = "#{Gem::Requirement.default_prerelease}"
764-
765-
str = ARGV.first
766-
if str
767-
str = str.b[/\\A_(.*)_\\z/, 1]
768-
if str and Gem::Version.correct?(str)
769-
#{explicit_version_requirement(spec.name)}
770-
ARGV.shift
771-
end
772-
end
752+
<<~TEXT
753+
#{shebang bin_file_name}
754+
#
755+
# This file was generated by RubyGems.
756+
#
757+
# The application '#{spec.name}' is installed as part of a gem, and
758+
# this file is here to facilitate running it.
759+
#
760+
761+
require 'rubygems'
762+
#{gemdeps_load(spec.name)}
763+
version = "#{Gem::Requirement.default_prerelease}"
764+
765+
str = ARGV.first
766+
if str
767+
str = str.b[/\\A_(.*)_\\z/, 1]
768+
if str and Gem::Version.correct?(str)
769+
#{explicit_version_requirement(spec.name)}
770+
ARGV.shift
771+
end
772+
end
773773
774-
load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version)
775-
TEXT
774+
load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version)
775+
TEXT
776776
end
777777

778778
def gemdeps_load(name)
779779
return "" if name == "bundler"
780780

781-
<<-TEXT
781+
<<~TEXT
782782
783-
Gem.use_gemdeps
784-
TEXT
783+
Gem.use_gemdeps
784+
TEXT
785785
end
786786

787787
def explicit_version_requirement(name)
788788
code = "version = str"
789789
return code unless name == "bundler"
790790

791-
code += <<-TEXT
791+
code += <<~TEXT
792792
793-
ENV['BUNDLER_VERSION'] = str
794-
TEXT
793+
ENV['BUNDLER_VERSION'] = str
794+
TEXT
795795
end
796796

797797
##
@@ -806,26 +806,26 @@ def windows_stub_script(bindir, bin_file_name)
806806

807807
if File.exist?(File.join(bindir, ruby_exe))
808808
# stub & ruby.exe within same folder. Portable
809-
<<-TEXT
810-
@ECHO OFF
811-
@"%~dp0#{ruby_exe}" "%~dpn0" %*
809+
<<~TEXT
810+
@ECHO OFF
811+
@"%~dp0#{ruby_exe}" "%~dpn0" %*
812812
TEXT
813813
elsif bindir.downcase.start_with? rb_topdir.downcase
814814
# stub within ruby folder, but not standard bin. Portable
815815
require "pathname"
816816
from = Pathname.new bindir
817817
to = Pathname.new "#{rb_topdir}/bin"
818818
rel = to.relative_path_from from
819-
<<-TEXT
820-
@ECHO OFF
821-
@"%~dp0#{rel}/#{ruby_exe}" "%~dpn0" %*
819+
<<~TEXT
820+
@ECHO OFF
821+
@"%~dp0#{rel}/#{ruby_exe}" "%~dpn0" %*
822822
TEXT
823823
else
824824
# outside ruby folder, maybe -user-install or bundler. Portable, but ruby
825825
# is dependent on PATH
826-
<<-TEXT
827-
@ECHO OFF
828-
@#{ruby_exe} "%~dpn0" %*
826+
<<~TEXT
827+
@ECHO OFF
828+
@#{ruby_exe} "%~dpn0" %*
829829
TEXT
830830
end
831831
end

test/rubygems/test_gem_installer.rb

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,31 @@ def test_app_script_text
2424

2525
util_make_exec @spec, ""
2626

27-
expected = <<-EOF
28-
#!#{Gem.ruby}
29-
#
30-
# This file was generated by RubyGems.
31-
#
32-
# The application 'a' is installed as part of a gem, and
33-
# this file is here to facilitate running it.
34-
#
35-
36-
require 'rubygems'
37-
38-
Gem.use_gemdeps
39-
40-
version = \">= 0.a\"
41-
42-
str = ARGV.first
43-
if str
44-
str = str.b[/\\A_(.*)_\\z/, 1]
45-
if str and Gem::Version.correct?(str)
46-
version = str
47-
ARGV.shift
48-
end
49-
end
27+
expected = <<~EOF
28+
#!#{Gem.ruby}
29+
#
30+
# This file was generated by RubyGems.
31+
#
32+
# The application 'a' is installed as part of a gem, and
33+
# this file is here to facilitate running it.
34+
#
35+
36+
require 'rubygems'
37+
38+
Gem.use_gemdeps
39+
40+
version = \">= 0.a\"
41+
42+
str = ARGV.first
43+
if str
44+
str = str.b[/\\A_(.*)_\\z/, 1]
45+
if str and Gem::Version.correct?(str)
46+
version = str
47+
ARGV.shift
48+
end
49+
end
5050
51-
load Gem.activate_bin_path('a', 'executable', version)
51+
load Gem.activate_bin_path('a', 'executable', version)
5252
EOF
5353

5454
wrapper = installer.app_script_text "executable"
@@ -116,12 +116,12 @@ def test_check_executable_overwrite_format_executable
116116
end
117117

118118
File.open File.join(util_inst_bindir, "executable"), "w" do |io|
119-
io.write <<-EXEC
120-
#!/usr/local/bin/ruby
121-
#
122-
# This file was generated by RubyGems
119+
io.write <<~EXEC
120+
#!/usr/local/bin/ruby
121+
#
122+
# This file was generated by RubyGems
123123
124-
gem 'other', version
124+
gem 'other', version
125125
EXEC
126126
end
127127

@@ -864,11 +864,11 @@ def test_use_plugin_immediately
864864
spec_version = spec.version
865865
plugin_path = File.join("lib", "rubygems_plugin.rb")
866866
write_file File.join(@tempdir, plugin_path) do |io|
867-
io.write <<-PLUGIN
868-
#{self.class}.plugin_loaded = true
869-
Gem.post_install do
870-
#{self.class}.post_install_is_called = true
871-
end
867+
io.write <<~PLUGIN
868+
#{self.class}.plugin_loaded = true
869+
Gem.post_install do
870+
#{self.class}.post_install_is_called = true
871+
end
872872
PLUGIN
873873
end
874874
spec.files += [plugin_path]
@@ -1552,7 +1552,7 @@ def test_find_lib_file_after_install
15521552
@spec = setup_base_spec
15531553
@spec.extensions << "extconf.rb"
15541554
write_dummy_extconf @spec.name do |io|
1555-
io.write <<-RUBY
1555+
io.write <<~RUBY
15561556
15571557
CONFIG['CC'] = '$(TOUCH) $@ ||'
15581558
CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
@@ -1564,7 +1564,7 @@ def test_find_lib_file_after_install
15641564
write_file File.join(@tempdir, "depend")
15651565

15661566
write_file File.join(@tempdir, "a.c") do |io|
1567-
io.write <<-C
1567+
io.write <<~C
15681568
#include <ruby.h>
15691569
void Init_a() { }
15701570
C
@@ -1601,7 +1601,7 @@ def test_install_extension_and_script
16011601
rb = File.join("lib", "#{@spec.name}.rb")
16021602
@spec.files += [rb]
16031603
write_file File.join(@tempdir, rb) do |io|
1604-
io.write <<-RUBY
1604+
io.write <<~RUBY
16051605
# #{@spec.name}.rb
16061606
RUBY
16071607
end
@@ -1610,7 +1610,7 @@ def test_install_extension_and_script
16101610
rb2 = File.join("lib", @spec.name, "#{@spec.name}.rb")
16111611
@spec.files << rb2
16121612
write_file File.join(@tempdir, rb2) do |io|
1613-
io.write <<-RUBY
1613+
io.write <<~RUBY
16141614
# #{@spec.name}/#{@spec.name}.rb
16151615
RUBY
16161616
end
@@ -1637,7 +1637,7 @@ def test_install_extension_flat
16371637
@spec.extensions << "extconf.rb"
16381638

16391639
write_dummy_extconf @spec.name do |io|
1640-
io.write <<-RUBY
1640+
io.write <<~RUBY
16411641
16421642
CONFIG['CC'] = '$(TOUCH) $@ ||'
16431643
CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'

0 commit comments

Comments
 (0)