Remove to_s from some Pathnames.
This commit is contained in:
parent
f1d4c4be78
commit
5828eefd01
@ -24,7 +24,7 @@ def require?(path)
|
||||
require path
|
||||
rescue LoadError => e
|
||||
# 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
|
||||
|
||||
begin
|
||||
|
||||
@ -35,10 +35,10 @@ module Hbc
|
||||
altnames = "(#{altnames})"
|
||||
|
||||
# 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",
|
||||
args: ["-w", ALT_NAME_ATTRIBUTE, altnames, file.to_s],
|
||||
args: ["-w", ALT_NAME_ATTRIBUTE, altnames, file],
|
||||
print_stderr: false)
|
||||
end
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ module Hbc
|
||||
if command.respond_to?(:run)
|
||||
# usual case: built-in command verb
|
||||
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
|
||||
elsif command.to_s.include?("/") && require?(command.to_s)
|
||||
# external command as Ruby library with literal path, useful
|
||||
|
||||
@ -94,7 +94,7 @@ module Homebrew
|
||||
|
||||
if files.nil?
|
||||
args << "--config" << HOMEBREW_LIBRARY_PATH/".rubocop.yml"
|
||||
args += [HOMEBREW_LIBRARY_PATH]
|
||||
args << HOMEBREW_LIBRARY_PATH
|
||||
else
|
||||
args << "--config" << HOMEBREW_LIBRARY/".rubocop.yml"
|
||||
args += files
|
||||
|
||||
@ -909,7 +909,7 @@ class FormulaAuditor
|
||||
end
|
||||
bin_names.each do |name|
|
||||
["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}")
|
||||
end
|
||||
end
|
||||
|
||||
@ -119,7 +119,7 @@ module Homebrew
|
||||
return unless which("python")
|
||||
|
||||
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
|
||||
|
||||
# Only warn if Python lives with Anaconda, since is most problematic case.
|
||||
|
||||
@ -63,9 +63,9 @@ class Keg
|
||||
# expensive recursive search if possible.
|
||||
def fixed_name(file, bad_name)
|
||||
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
|
||||
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?
|
||||
"@loader_path/#{bad_name}"
|
||||
elsif file.mach_o_executable? && (lib + bad_name).exist?
|
||||
|
||||
@ -3,7 +3,7 @@ HOMEBREW_TAP_FORMULA_REGEX = %r{^([\w-]+)/([\w-]+)/([\w+-.@]+)$}
|
||||
# match taps' casks, e.g. someuser/sometap/somecask
|
||||
HOMEBREW_TAP_CASK_REGEX = %r{^([\w-]+)/([\w-]+)/([a-z0-9\-]+)$}
|
||||
# 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
|
||||
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
|
||||
|
||||
@ -9,7 +9,7 @@ describe "brew --env", :integration_test do
|
||||
describe "--shell=bash" do
|
||||
it "prints the Homebrew build environment variables in Bash syntax" do
|
||||
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 be_a_success
|
||||
end
|
||||
@ -18,7 +18,7 @@ describe "brew --env", :integration_test do
|
||||
describe "--shell=fish" do
|
||||
it "prints the Homebrew build environment variables in Fish syntax" do
|
||||
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 be_a_success
|
||||
end
|
||||
@ -27,7 +27,7 @@ describe "brew --env", :integration_test do
|
||||
describe "--shell=tcsh" do
|
||||
it "prints the Homebrew build environment variables in Tcsh syntax" do
|
||||
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 be_a_success
|
||||
end
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
describe "brew --version", :integration_test do
|
||||
it "prints the Homebrew version" do
|
||||
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 be_a_success
|
||||
end
|
||||
|
||||
@ -24,7 +24,7 @@ shared_examples Hbc::Staged do
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
backtrace = caller
|
||||
tap_message = nil
|
||||
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_message = "\nPlease report this to the #{tap} tap!"
|
||||
true
|
||||
|
||||
@ -164,7 +164,7 @@ module GitHub
|
||||
args += ["--data", "@#{data_tmpfile.path}"]
|
||||
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, _, http_code = output.rpartition("\n")
|
||||
|
||||
@ -307,7 +307,7 @@ class Version
|
||||
spec_s = spec.to_s
|
||||
|
||||
stem = if spec.directory?
|
||||
spec.basename.to_s
|
||||
spec.basename
|
||||
elsif %r{((?:sourceforge\.net|sf\.net)/.*)/download$} =~ spec_s
|
||||
Pathname.new(spec.dirname).stem
|
||||
elsif /\.[^a-zA-Z]+$/ =~ spec_s
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user