Skip to content

Commit f0dc1d9

Browse files
authored
Merge pull request #2537 from reitermarkus/pathname-to_str
Remove `to_s` from some `Pathname`s.
2 parents 2b72638 + 5828eef commit f0dc1d9

File tree

14 files changed

+18
-18
lines changed

14 files changed

+18
-18
lines changed

Library/Homebrew/brew.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def require?(path)
2424
require path
2525
rescue LoadError => e
2626
# we should raise on syntax errors but not if the file doesn't exist.
27-
raise unless e.to_s.include? path
27+
raise unless e.message.include?(path)
2828
end
2929

3030
begin

Library/Homebrew/cask/lib/hbc/artifact/relocated.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ def add_altname_metadata(file, altname)
3535
altnames = "(#{altnames})"
3636

3737
# Some packges are shipped as u=rx (e.g. Bitcoin Core)
38-
@command.run!("/bin/chmod", args: ["--", "u+rw", file.to_s, file.realpath.to_s])
38+
@command.run!("/bin/chmod", args: ["--", "u+rw", file, file.realpath])
3939

4040
@command.run!("/usr/bin/xattr",
41-
args: ["-w", ALT_NAME_ATTRIBUTE, altnames, file.to_s],
41+
args: ["-w", ALT_NAME_ATTRIBUTE, altnames, file],
4242
print_stderr: false)
4343
end
4444

Library/Homebrew/cask/lib/hbc/cli.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def self.run_command(command, *rest)
113113
if command.respond_to?(:run)
114114
# usual case: built-in command verb
115115
command.run(*rest)
116-
elsif require? which("brewcask-#{command}.rb").to_s
116+
elsif require?(which("brewcask-#{command}.rb"))
117117
# external command as Ruby library on PATH, Homebrew-style
118118
elsif command.to_s.include?("/") && require?(command.to_s)
119119
# external command as Ruby library with literal path, useful

Library/Homebrew/cmd/style.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def check_style_impl(files, output_type, options = {})
9494

9595
if files.nil?
9696
args << "--config" << HOMEBREW_LIBRARY_PATH/".rubocop.yml"
97-
args += [HOMEBREW_LIBRARY_PATH]
97+
args << HOMEBREW_LIBRARY_PATH
9898
else
9999
args << "--config" << HOMEBREW_LIBRARY/".rubocop.yml"
100100
args += files

Library/Homebrew/dev-cmd/audit.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ def audit_text
856856
end
857857
bin_names.each do |name|
858858
["system", "shell_output", "pipe_output"].each do |cmd|
859-
if text =~ %r{(def test|test do).*(#{Regexp.escape HOMEBREW_PREFIX}/bin/)?#{cmd}[\(\s]+['"]#{Regexp.escape name}[\s'"]}m
859+
if text =~ %r{(def test|test do).*(#{Regexp.escape(HOMEBREW_PREFIX)}/bin/)?#{cmd}[\(\s]+['"]#{Regexp.escape(name)}[\s'"]}m
860860
problem %Q(fully scope test #{cmd} calls e.g. #{cmd} "\#{bin}/#{name}")
861861
end
862862
end

Library/Homebrew/diagnostic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def check_for_anaconda
119119
return unless which("python")
120120

121121
anaconda_directory = which("anaconda").realpath.dirname
122-
python_binary = Utils.popen_read which("python"), "-c", "import sys; sys.stdout.write(sys.executable)"
122+
python_binary = Utils.popen_read(which("python"), "-c", "import sys; sys.stdout.write(sys.executable)")
123123
python_directory = Pathname.new(python_binary).realpath.dirname
124124

125125
# Only warn if Python lives with Anaconda, since is most problematic case.

Library/Homebrew/extend/os/mac/keg_relocate.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def detect_cxx_stdlibs(options = {})
6363
# expensive recursive search if possible.
6464
def fixed_name(file, bad_name)
6565
if bad_name.start_with? PREFIX_PLACEHOLDER
66-
bad_name.sub(PREFIX_PLACEHOLDER, HOMEBREW_PREFIX.to_s)
66+
bad_name.sub(PREFIX_PLACEHOLDER, HOMEBREW_PREFIX)
6767
elsif bad_name.start_with? CELLAR_PLACEHOLDER
68-
bad_name.sub(CELLAR_PLACEHOLDER, HOMEBREW_CELLAR.to_s)
68+
bad_name.sub(CELLAR_PLACEHOLDER, HOMEBREW_CELLAR)
6969
elsif (file.dylib? || file.mach_o_bundle?) && (file.parent + bad_name).exist?
7070
"@loader_path/#{bad_name}"
7171
elsif file.mach_o_executable? && (lib + bad_name).exist?

Library/Homebrew/tap_constants.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# match taps' casks, e.g. someuser/sometap/somecask
44
HOMEBREW_TAP_CASK_REGEX = %r{^([\w-]+)/([\w-]+)/([a-z0-9\-]+)$}
55
# match taps' directory paths, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap
6-
HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/([\w-]+)/([\w-]+)}
6+
HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY)}/Taps/([\w-]+)/([\w-]+)}
77
# match taps' formula paths, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula
88
HOMEBREW_TAP_PATH_REGEX = Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{/(.*)}.source)
99
# match the default and the versions brew-cask tap e.g. Caskroom/cask or Caskroom/versions

Library/Homebrew/test/cmd/--env_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
describe "--shell=bash" do
1010
it "prints the Homebrew build environment variables in Bash syntax" do
1111
expect { brew "--env", "--shell=bash" }
12-
.to output(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/).to_stdout
12+
.to output(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX)}"/).to_stdout
1313
.and not_to_output.to_stderr
1414
.and be_a_success
1515
end
@@ -18,7 +18,7 @@
1818
describe "--shell=fish" do
1919
it "prints the Homebrew build environment variables in Fish syntax" do
2020
expect { brew "--env", "--shell=fish" }
21-
.to output(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/).to_stdout
21+
.to output(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX)}"/).to_stdout
2222
.and not_to_output.to_stderr
2323
.and be_a_success
2424
end
@@ -27,7 +27,7 @@
2727
describe "--shell=tcsh" do
2828
it "prints the Homebrew build environment variables in Tcsh syntax" do
2929
expect { brew "--env", "--shell=tcsh" }
30-
.to output(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};/).to_stdout
30+
.to output(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX)};/).to_stdout
3131
.and not_to_output.to_stderr
3232
.and be_a_success
3333
end

Library/Homebrew/test/cmd/--version_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe "brew --version", :integration_test do
22
it "prints the Homebrew version" do
33
expect { brew "--version" }
4-
.to output(/^Homebrew #{Regexp.escape(HOMEBREW_VERSION.to_s)}\n/).to_stdout
4+
.to output(/^Homebrew #{Regexp.escape(HOMEBREW_VERSION)}\n/).to_stdout
55
.and not_to_output.to_stderr
66
.and be_a_success
77
end

0 commit comments

Comments
 (0)