Skip to content
Snippets Groups Projects
Commit 5828eefd authored by Markus Reiter's avatar Markus Reiter
Browse files

Remove `to_s` from some `Pathname`s.

parent f1d4c4be
No related branches found
No related tags found
No related merge requests found
Showing with 18 additions and 18 deletions
...@@ -24,7 +24,7 @@ def require?(path) ...@@ -24,7 +24,7 @@ def require?(path)
require path require path
rescue LoadError => e rescue LoadError => e
# we should raise on syntax errors but not if the file doesn't exist. # we should raise on syntax errors but not if the file doesn't exist.
raise unless e.to_s.include? path raise unless e.message.include?(path)
end end
begin begin
......
...@@ -35,10 +35,10 @@ module Hbc ...@@ -35,10 +35,10 @@ module Hbc
altnames = "(#{altnames})" altnames = "(#{altnames})"
# Some packges are shipped as u=rx (e.g. Bitcoin Core) # Some packges are shipped as u=rx (e.g. Bitcoin Core)
@command.run!("/bin/chmod", args: ["--", "u+rw", file.to_s, file.realpath.to_s]) @command.run!("/bin/chmod", args: ["--", "u+rw", file, file.realpath])
@command.run!("/usr/bin/xattr", @command.run!("/usr/bin/xattr",
args: ["-w", ALT_NAME_ATTRIBUTE, altnames, file.to_s], args: ["-w", ALT_NAME_ATTRIBUTE, altnames, file],
print_stderr: false) print_stderr: false)
end end
......
...@@ -113,7 +113,7 @@ module Hbc ...@@ -113,7 +113,7 @@ module Hbc
if command.respond_to?(:run) if command.respond_to?(:run)
# usual case: built-in command verb # usual case: built-in command verb
command.run(*rest) command.run(*rest)
elsif require? which("brewcask-#{command}.rb").to_s elsif require?(which("brewcask-#{command}.rb"))
# external command as Ruby library on PATH, Homebrew-style # external command as Ruby library on PATH, Homebrew-style
elsif command.to_s.include?("/") && require?(command.to_s) elsif command.to_s.include?("/") && require?(command.to_s)
# external command as Ruby library with literal path, useful # external command as Ruby library with literal path, useful
......
...@@ -94,7 +94,7 @@ module Homebrew ...@@ -94,7 +94,7 @@ module Homebrew
if files.nil? if files.nil?
args << "--config" << HOMEBREW_LIBRARY_PATH/".rubocop.yml" args << "--config" << HOMEBREW_LIBRARY_PATH/".rubocop.yml"
args += [HOMEBREW_LIBRARY_PATH] args << HOMEBREW_LIBRARY_PATH
else else
args << "--config" << HOMEBREW_LIBRARY/".rubocop.yml" args << "--config" << HOMEBREW_LIBRARY/".rubocop.yml"
args += files args += files
......
...@@ -909,7 +909,7 @@ class FormulaAuditor ...@@ -909,7 +909,7 @@ class FormulaAuditor
end end
bin_names.each do |name| bin_names.each do |name|
["system", "shell_output", "pipe_output"].each do |cmd| ["system", "shell_output", "pipe_output"].each do |cmd|
if text =~ %r{(def test|test do).*(#{Regexp.escape HOMEBREW_PREFIX}/bin/)?#{cmd}[\(\s]+['"]#{Regexp.escape name}[\s'"]}m if text =~ %r{(def test|test do).*(#{Regexp.escape(HOMEBREW_PREFIX)}/bin/)?#{cmd}[\(\s]+['"]#{Regexp.escape(name)}[\s'"]}m
problem %Q(fully scope test #{cmd} calls e.g. #{cmd} "\#{bin}/#{name}") problem %Q(fully scope test #{cmd} calls e.g. #{cmd} "\#{bin}/#{name}")
end end
end end
......
...@@ -119,7 +119,7 @@ module Homebrew ...@@ -119,7 +119,7 @@ module Homebrew
return unless which("python") return unless which("python")
anaconda_directory = which("anaconda").realpath.dirname anaconda_directory = which("anaconda").realpath.dirname
python_binary = Utils.popen_read which("python"), "-c", "import sys; sys.stdout.write(sys.executable)" python_binary = Utils.popen_read(which("python"), "-c", "import sys; sys.stdout.write(sys.executable)")
python_directory = Pathname.new(python_binary).realpath.dirname python_directory = Pathname.new(python_binary).realpath.dirname
# Only warn if Python lives with Anaconda, since is most problematic case. # Only warn if Python lives with Anaconda, since is most problematic case.
......
...@@ -63,9 +63,9 @@ class Keg ...@@ -63,9 +63,9 @@ class Keg
# expensive recursive search if possible. # expensive recursive search if possible.
def fixed_name(file, bad_name) def fixed_name(file, bad_name)
if bad_name.start_with? PREFIX_PLACEHOLDER if bad_name.start_with? PREFIX_PLACEHOLDER
bad_name.sub(PREFIX_PLACEHOLDER, HOMEBREW_PREFIX.to_s) bad_name.sub(PREFIX_PLACEHOLDER, HOMEBREW_PREFIX)
elsif bad_name.start_with? CELLAR_PLACEHOLDER elsif bad_name.start_with? CELLAR_PLACEHOLDER
bad_name.sub(CELLAR_PLACEHOLDER, HOMEBREW_CELLAR.to_s) bad_name.sub(CELLAR_PLACEHOLDER, HOMEBREW_CELLAR)
elsif (file.dylib? || file.mach_o_bundle?) && (file.parent + bad_name).exist? elsif (file.dylib? || file.mach_o_bundle?) && (file.parent + bad_name).exist?
"@loader_path/#{bad_name}" "@loader_path/#{bad_name}"
elsif file.mach_o_executable? && (lib + bad_name).exist? elsif file.mach_o_executable? && (lib + bad_name).exist?
......
...@@ -3,7 +3,7 @@ HOMEBREW_TAP_FORMULA_REGEX = %r{^([\w-]+)/([\w-]+)/([\w+-.@]+)$} ...@@ -3,7 +3,7 @@ HOMEBREW_TAP_FORMULA_REGEX = %r{^([\w-]+)/([\w-]+)/([\w+-.@]+)$}
# match taps' casks, e.g. someuser/sometap/somecask # match taps' casks, e.g. someuser/sometap/somecask
HOMEBREW_TAP_CASK_REGEX = %r{^([\w-]+)/([\w-]+)/([a-z0-9\-]+)$} HOMEBREW_TAP_CASK_REGEX = %r{^([\w-]+)/([\w-]+)/([a-z0-9\-]+)$}
# match taps' directory paths, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap # match taps' directory paths, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap
HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY.to_s)}/Taps/([\w-]+)/([\w-]+)} HOMEBREW_TAP_DIR_REGEX = %r{#{Regexp.escape(HOMEBREW_LIBRARY)}/Taps/([\w-]+)/([\w-]+)}
# match taps' formula paths, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula # match taps' formula paths, e.g. HOMEBREW_LIBRARY/Taps/someuser/sometap/someformula
HOMEBREW_TAP_PATH_REGEX = Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{/(.*)}.source) HOMEBREW_TAP_PATH_REGEX = Regexp.new(HOMEBREW_TAP_DIR_REGEX.source + %r{/(.*)}.source)
# match the default and the versions brew-cask tap e.g. Caskroom/cask or Caskroom/versions # match the default and the versions brew-cask tap e.g. Caskroom/cask or Caskroom/versions
......
...@@ -9,7 +9,7 @@ describe "brew --env", :integration_test do ...@@ -9,7 +9,7 @@ describe "brew --env", :integration_test do
describe "--shell=bash" do describe "--shell=bash" do
it "prints the Homebrew build environment variables in Bash syntax" do it "prints the Homebrew build environment variables in Bash syntax" do
expect { brew "--env", "--shell=bash" } expect { brew "--env", "--shell=bash" }
.to output(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/).to_stdout .to output(/export CMAKE_PREFIX_PATH="#{Regexp.quote(HOMEBREW_PREFIX)}"/).to_stdout
.and not_to_output.to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
end end
...@@ -18,7 +18,7 @@ describe "brew --env", :integration_test do ...@@ -18,7 +18,7 @@ describe "brew --env", :integration_test do
describe "--shell=fish" do describe "--shell=fish" do
it "prints the Homebrew build environment variables in Fish syntax" do it "prints the Homebrew build environment variables in Fish syntax" do
expect { brew "--env", "--shell=fish" } expect { brew "--env", "--shell=fish" }
.to output(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX.to_s)}"/).to_stdout .to output(/set [-]gx CMAKE_PREFIX_PATH "#{Regexp.quote(HOMEBREW_PREFIX)}"/).to_stdout
.and not_to_output.to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
end end
...@@ -27,7 +27,7 @@ describe "brew --env", :integration_test do ...@@ -27,7 +27,7 @@ describe "brew --env", :integration_test do
describe "--shell=tcsh" do describe "--shell=tcsh" do
it "prints the Homebrew build environment variables in Tcsh syntax" do it "prints the Homebrew build environment variables in Tcsh syntax" do
expect { brew "--env", "--shell=tcsh" } expect { brew "--env", "--shell=tcsh" }
.to output(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX.to_s)};/).to_stdout .to output(/setenv CMAKE_PREFIX_PATH #{Regexp.quote(HOMEBREW_PREFIX)};/).to_stdout
.and not_to_output.to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
end end
......
describe "brew --version", :integration_test do describe "brew --version", :integration_test do
it "prints the Homebrew version" do it "prints the Homebrew version" do
expect { brew "--version" } expect { brew "--version" }
.to output(/^Homebrew #{Regexp.escape(HOMEBREW_VERSION.to_s)}\n/).to_stdout .to output(/^Homebrew #{Regexp.escape(HOMEBREW_VERSION)}\n/).to_stdout
.and not_to_output.to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
end end
......
...@@ -24,7 +24,7 @@ shared_examples Hbc::Staged do ...@@ -24,7 +24,7 @@ shared_examples Hbc::Staged do
end end
it "can get the Info.plist file for the primary app" do it "can get the Info.plist file for the primary app" do
expect(staged.info_plist_file.to_s).to include Hbc.appdir.join("TestCask.app/Contents/Info.plist") expect(staged.info_plist_file).to eq Hbc.appdir.join("TestCask.app/Contents/Info.plist")
end end
it "can execute commands on the Info.plist file" do it "can execute commands on the Info.plist file" do
......
...@@ -75,7 +75,7 @@ def odeprecated(method, replacement = nil, disable: false, disable_on: nil, call ...@@ -75,7 +75,7 @@ def odeprecated(method, replacement = nil, disable: false, disable_on: nil, call
backtrace = caller backtrace = caller
tap_message = nil tap_message = nil
caller_message = backtrace.detect do |line| caller_message = backtrace.detect do |line|
next unless line =~ %r{^#{Regexp.escape HOMEBREW_LIBRARY}/Taps/([^/]+/[^/]+)/} next unless line =~ %r{^#{Regexp.escape(HOMEBREW_LIBRARY)}/Taps/([^/]+/[^/]+)/}
tap = Tap.fetch $1 tap = Tap.fetch $1
tap_message = "\nPlease report this to the #{tap} tap!" tap_message = "\nPlease report this to the #{tap} tap!"
true true
......
...@@ -164,7 +164,7 @@ module GitHub ...@@ -164,7 +164,7 @@ module GitHub
args += ["--data", "@#{data_tmpfile.path}"] args += ["--data", "@#{data_tmpfile.path}"]
end end
args += ["--dump-header", headers_tmpfile.path.to_s] args += ["--dump-header", headers_tmpfile.path]
output, errors, status = curl_output(url.to_s, *args) output, errors, status = curl_output(url.to_s, *args)
output, _, http_code = output.rpartition("\n") output, _, http_code = output.rpartition("\n")
......
...@@ -307,7 +307,7 @@ class Version ...@@ -307,7 +307,7 @@ class Version
spec_s = spec.to_s spec_s = spec.to_s
stem = if spec.directory? stem = if spec.directory?
spec.basename.to_s spec.basename
elsif %r{((?:sourceforge\.net|sf\.net)/.*)/download$} =~ spec_s elsif %r{((?:sourceforge\.net|sf\.net)/.*)/download$} =~ spec_s
Pathname.new(spec.dirname).stem Pathname.new(spec.dirname).stem
elsif /\.[^a-zA-Z]+$/ =~ spec_s elsif /\.[^a-zA-Z]+$/ =~ spec_s
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment