Skip to content

Commit

Permalink
Merge pull request #8428 from rolandwalker/remove_homebrew_pathname_s…
Browse files Browse the repository at this point in the history
…lash_monkeypatch

remove homebrew-fork `Pathname#/` monkeypatch
  • Loading branch information
rolandwalker committed Dec 26, 2014
2 parents 6557cfe + 05d6afa commit be4f975
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 115 deletions.
8 changes: 0 additions & 8 deletions lib/homebrew-fork/Library/Homebrew/extend/pathname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,4 @@ def rmdir_if_possible

# FIXME eliminate the places where we rely on this method
alias_method :to_str, :to_s unless method_defined?(:to_str)

def /(other)
unless other.respond_to?(:to_str) || other.respond_to?(:to_path)
opoo "Pathname#/ called on #{inspect} with #{other.inspect} as an argument"
puts "This behavior is deprecated, please pass either a String or a Pathname"
end
self + other.to_s
end unless method_defined?(:/)
end
2 changes: 1 addition & 1 deletion lib/homebrew-fork/Library/Homebrew/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def mkpath

HOMEBREW_PREFIX = Pathname.new(HOMEBREW_BREW_FILE).dirname.parent # Where we link under
HOMEBREW_REPOSITORY = Pathname.new(HOMEBREW_BREW_FILE).realpath.dirname.parent # Where .git is found
HOMEBREW_LIBRARY = HOMEBREW_REPOSITORY/"Library"
HOMEBREW_LIBRARY = HOMEBREW_REPOSITORY.join('Library')

HOMEBREW_TEMP = Pathname.new(ENV.fetch('HOMEBREW_TEMP', '/tmp'))

Expand Down
4 changes: 2 additions & 2 deletions lib/homebrew-fork/Library/Homebrew/os/mac/xquartz.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ def installed?
end

def bin
prefix/"bin"
prefix.join("bin")
end

def share
prefix/"share"
prefix.join("share")
end
end
end
Expand Down
22 changes: 11 additions & 11 deletions test/cask/artifact/alt_target_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Cask::Artifact::App.new(cask).install_phase
end

TestHelper.valid_alias?(Cask.appdir/'AnotherName.app').must_equal true
TestHelper.valid_alias?(Cask.appdir.join('AnotherName.app')).must_equal true
end

it "creates metadata containing the alternate target name" do
Expand All @@ -28,7 +28,7 @@
Cask::SystemCommand.run('/usr/bin/xattr',
:args => ['-p',
'com.apple.metadata:kMDItemAlternateNames',
Cask.appdir/'AnotherName.app'],
Cask.appdir.join('AnotherName.app')],
:print_stderr => false).stdout.must_match(/AnotherName/)
end

Expand All @@ -47,14 +47,14 @@
TestHelper.install_without_artifacts(cask)
end

appsubdir = (subdir_cask.staged_path/'subdir').tap(&:mkpath)
FileUtils.mv((subdir_cask.staged_path/'Caffeine.app'), appsubdir)
appsubdir = subdir_cask.staged_path.join('subdir').tap(&:mkpath)
FileUtils.mv(subdir_cask.staged_path.join('Caffeine.app'), appsubdir)

shutup do
Cask::Artifact::App.new(subdir_cask).install_phase
end

TestHelper.valid_alias?(Cask.appdir/'AnotherName.app').must_equal true
TestHelper.valid_alias?(Cask.appdir.join('AnotherName.app')).must_equal true
ensure
if defined?(subdir_cask)
shutup do
Expand All @@ -74,32 +74,32 @@
Cask::Artifact::App.new(cask).install_phase
end

TestHelper.valid_alias?(Cask.appdir/'AnotherName.app').must_equal true
TestHelper.valid_alias?(Cask.appdir/'AnotherNameAgain.app').must_equal false
TestHelper.valid_alias?(Cask.appdir.join('AnotherName.app')).must_equal true
TestHelper.valid_alias?(Cask.appdir.join('AnotherNameAgain.app')).must_equal false
end

it "avoids clobbering an existing app by linking over it" do
cask = local_alt_caffeine

(Cask.appdir/'AnotherName.app').mkpath
Cask.appdir.join('AnotherName.app').mkpath

TestHelper.must_output(self, lambda {
Cask::Artifact::App.new(cask).install_phase
}, "==> It seems there is already an App at '#{Cask.appdir.join('AnotherName.app')}'; not linking.")

(Cask.appdir/'AnotherName.app').wont_be :symlink?
Cask.appdir.join('AnotherName.app').wont_be :symlink?
end

it "happily clobbers an existing symlink" do
cask = local_alt_caffeine

(Cask.appdir/'AnotherName.app').make_symlink('/tmp')
Cask.appdir.join('AnotherName.app').make_symlink('/tmp')

TestHelper.must_output(self, lambda {
Cask::Artifact::App.new(cask).install_phase
}, "==> Symlinking App 'Caffeine.app' to '#{Cask.appdir.join('AnotherName.app')}'")

File.readlink(Cask.appdir/'AnotherName.app').wont_equal '/tmp'
File.readlink(Cask.appdir.join('AnotherName.app')).wont_equal '/tmp'
end
end
end
20 changes: 10 additions & 10 deletions test/cask/artifact/app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Cask::Artifact::App.new(cask).install_phase
end

TestHelper.valid_alias?(Cask.appdir/'Caffeine.app').must_equal true
TestHelper.valid_alias?(Cask.appdir.join('Caffeine.app')).must_equal true
end

it "works with an application in a subdir" do
Expand All @@ -33,14 +33,14 @@
TestHelper.install_without_artifacts(cask)
end

appsubdir = (subdir_cask.staged_path/'subdir').tap(&:mkpath)
FileUtils.mv((subdir_cask.staged_path/'Caffeine.app'), appsubdir)
appsubdir = subdir_cask.staged_path.join('subdir').tap(&:mkpath)
FileUtils.mv(subdir_cask.staged_path.join('Caffeine.app'), appsubdir)

shutup do
Cask::Artifact::App.new(subdir_cask).install_phase
end

TestHelper.valid_alias?(Cask.appdir/'Caffeine.app').must_equal true
TestHelper.valid_alias?(Cask.appdir.join('Caffeine.app')).must_equal true
ensure
if defined?(subdir_cask)
shutup do
Expand All @@ -60,32 +60,32 @@
Cask::Artifact::App.new(cask).install_phase
end

TestHelper.valid_alias?(Cask.appdir/'Caffeine.app').must_equal true
TestHelper.valid_alias?(Cask.appdir/'CaffeineAgain.app').must_equal false
TestHelper.valid_alias?(Cask.appdir.join('Caffeine.app')).must_equal true
TestHelper.valid_alias?(Cask.appdir.join('CaffeineAgain.app')).must_equal false
end

it "avoids clobbering an existing app by linking over it" do
cask = local_caffeine

(Cask.appdir/'Caffeine.app').mkpath
Cask.appdir.join('Caffeine.app').mkpath

TestHelper.must_output(self, lambda {
Cask::Artifact::App.new(cask).install_phase
}, "==> It seems there is already an App at '#{Cask.appdir.join('Caffeine.app')}'; not linking.")

(Cask.appdir/'Caffeine.app').wont_be :symlink?
Cask.appdir.join('Caffeine.app').wont_be :symlink?
end

it "happily clobbers an existing symlink" do
cask = local_caffeine

(Cask.appdir/'Caffeine.app').make_symlink('/tmp')
Cask.appdir.join('Caffeine.app').make_symlink('/tmp')

TestHelper.must_output(self, lambda {
Cask::Artifact::App.new(cask).install_phase
}, "==> Symlinking App 'Caffeine.app' to '#{Cask.appdir.join('Caffeine.app')}'")

File.readlink(Cask.appdir/'Caffeine.app').wont_equal '/tmp'
File.readlink(Cask.appdir.join('Caffeine.app')).wont_equal '/tmp'
end
end
end
2 changes: 1 addition & 1 deletion test/cask/artifact/binary_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
end
}
let(:expected_path) {
Cask.binarydir/'binary'
Cask.binarydir.join('binary')
}

it "links the binary to the proper directory" do
Expand Down
2 changes: 1 addition & 1 deletion test/cask/artifact/pkg_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
it 'runs the system installer on the specified pkgs' do
pkg = Cask::Artifact::Pkg.new(@cask, Cask::FakeSystemCommand)

Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/installer', '-pkg', @cask.staged_path/'MyFancyPkg'/'Fancy.pkg', '-target', '/'])
Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/usr/sbin/installer', '-pkg', @cask.staged_path.join('MyFancyPkg','Fancy.pkg'), '-target', '/'])

shutup do
pkg.install_phase
Expand Down
2 changes: 1 addition & 1 deletion test/cask/artifact/suite_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
end
}
let(:expected_path) {
Cask.appdir/'caffeine_suite'
Cask.appdir.join('caffeine_suite')
}

it "links the suite to the proper directory" do
Expand Down
32 changes: 16 additions & 16 deletions test/cask/artifact/two_apps_correct_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
Cask::Artifact::App.new(cask).install_phase
end

TestHelper.valid_alias?(Cask.appdir/'Caffeine.app').must_equal true
TestHelper.valid_alias?(Cask.appdir/'AnotherName.app').must_equal true
TestHelper.valid_alias?(Cask.appdir.join('Caffeine.app')).must_equal true
TestHelper.valid_alias?(Cask.appdir.join('AnotherName.app')).must_equal true
end

it "works with an application in a subdir" do
Expand All @@ -35,15 +35,15 @@
TestHelper.install_without_artifacts(cask)
end

appsubdir = (subdir_cask.staged_path/'subdir').tap(&:mkpath)
FileUtils.mv((subdir_cask.staged_path/'Caffeine.app'), appsubdir)
appsubdir = subdir_cask.staged_path.join('subdir').tap(&:mkpath)
FileUtils.mv(subdir_cask.staged_path.join('Caffeine.app'), appsubdir)

shutup do
Cask::Artifact::App.new(subdir_cask).install_phase
end

TestHelper.valid_alias?(Cask.appdir/'Caffeine.app').must_equal true
TestHelper.valid_alias?(Cask.appdir/'AnotherName.app').must_equal true
TestHelper.valid_alias?(Cask.appdir.join('Caffeine.app')).must_equal true
TestHelper.valid_alias?(Cask.appdir.join('AnotherName.app')).must_equal true
ensure
if defined?(subdir_cask)
shutup do
Expand All @@ -64,14 +64,14 @@
# Cask::Artifact::App.new(cask).install_phase
# end
#
# TestHelper.valid_alias?(Cask.appdir/'AnotherName.app').must_equal true
# TestHelper.valid_alias?(Cask.appdir/'AnotherNameAgain.app').must_equal false
# TestHelper.valid_alias?(Cask.appdir.join('AnotherName.app')).must_equal true
# TestHelper.valid_alias?(Cask.appdir.join('AnotherNameAgain.app').must_equal false
# end

it "avoids clobbering an existing app by linking over it (link 1)" do
cask = local_two_apps_caffeine

(Cask.appdir/'Caffeine.app').mkpath
Cask.appdir.join('Caffeine.app').mkpath

TestHelper.must_output(self, lambda {
Cask::Artifact::App.new(cask).install_phase
Expand All @@ -80,13 +80,13 @@
==> Symlinking App 'Caffeine.app' to '#{Cask.appdir.join('AnotherName.app')}'
MESSAGE

(Cask.appdir/'Caffeine.app').wont_be :symlink?
Cask.appdir.join('Caffeine.app').wont_be :symlink?
end

it "avoids clobbering an existing app by linking over it (link 2)" do
cask = local_two_apps_caffeine

(Cask.appdir/'AnotherName.app').mkpath
Cask.appdir.join('AnotherName.app').mkpath

TestHelper.must_output(self, lambda {
Cask::Artifact::App.new(cask).install_phase
Expand All @@ -95,13 +95,13 @@
==> It seems there is already an App at '#{Cask.appdir.join('AnotherName.app')}'; not linking.
MESSAGE

(Cask.appdir/'AnotherName.app').wont_be :symlink?
Cask.appdir.join('AnotherName.app').wont_be :symlink?
end

it "happily clobbers an existing symlink (link 1)" do
cask = local_two_apps_caffeine

(Cask.appdir/'Caffeine.app').make_symlink('/tmp')
Cask.appdir.join('Caffeine.app').make_symlink('/tmp')

TestHelper.must_output(self, lambda {
Cask::Artifact::App.new(cask).install_phase
Expand All @@ -110,13 +110,13 @@
==> Symlinking App 'Caffeine.app' to '#{Cask.appdir.join('AnotherName.app')}'
MESSAGE

File.readlink(Cask.appdir/'Caffeine.app').wont_equal '/tmp'
File.readlink(Cask.appdir.join('Caffeine.app')).wont_equal '/tmp'
end

it "happily clobbers an existing symlink (link 2)" do
cask = local_two_apps_caffeine

(Cask.appdir/'AnotherName.app').make_symlink('/tmp')
Cask.appdir.join('AnotherName.app').make_symlink('/tmp')

TestHelper.must_output(self, lambda {
Cask::Artifact::App.new(cask).install_phase
Expand All @@ -125,7 +125,7 @@
==> Symlinking App 'Caffeine.app' to '#{Cask.appdir.join('AnotherName.app')}'
MESSAGE

File.readlink(Cask.appdir/'AnotherName.app').wont_equal '/tmp'
File.readlink(Cask.appdir.join('AnotherName.app')).wont_equal '/tmp'
end
end
end
18 changes: 9 additions & 9 deletions test/cask/artifact/uninstall_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1')
Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit'])

Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', @cask.staged_path/'MyFancyPkg'/'FancyUninstaller.tool', '--please'])
Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', @cask.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please'])
Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--', '/permissible/absolute/path'])
Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-f', '--', Pathname.new(TestHelper.local_binary_path('empty_directory')).join('.DS_Store')])
Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rmdir', '--', Pathname.new(TestHelper.local_binary_path('empty_directory'))])
Expand Down Expand Up @@ -105,14 +105,14 @@
['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'list', 'my.fancy.package.service'],
<<-"PLIST"
{
"LimitLoadToSessionType" = "Aqua";
"Label" = "my.fancy.package.service";
"TimeOut" = 30;
"OnDemand" = true;
"LastExitStatus" = 0;
"ProgramArguments" = (
"argument";
);
"LimitLoadToSessionType" = "Aqua";
"Label" = "my.fancy.package.service";
"TimeOut" = 30;
"OnDemand" = true;
"LastExitStatus" = 0;
"ProgramArguments" = (
"argument";
);
};
PLIST
)
Expand Down
18 changes: 9 additions & 9 deletions test/cask/artifact/zap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"'], '1')
Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app" to quit'])

Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', @cask.staged_path/'MyFancyPkg'/'FancyUninstaller.tool', '--please'])
Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', @cask.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please'])
Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--',
Pathname.new('~/Library/Preferences/my.fancy.app.plist').expand_path])

Expand Down Expand Up @@ -107,14 +107,14 @@
['/usr/bin/sudo', '-E', '--', '/bin/launchctl', 'list', 'my.fancy.package.service'],
<<-"PLIST"
{
"LimitLoadToSessionType" = "Aqua";
"Label" = "my.fancy.package.service";
"TimeOut" = 30;
"OnDemand" = true;
"LastExitStatus" = 0;
"ProgramArguments" = (
"argument";
);
"LimitLoadToSessionType" = "Aqua";
"Label" = "my.fancy.package.service";
"TimeOut" = 30;
"OnDemand" = true;
"LastExitStatus" = 0;
"ProgramArguments" = (
"argument";
);
};
PLIST
)
Expand Down
2 changes: 1 addition & 1 deletion test/cask/cli/zap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
# Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app.from.uninstall"'], '1')
# Cask::FakeSystemCommand.stubs_command(['/usr/bin/sudo', '-E', '--', '/usr/bin/osascript', '-e', 'tell application id "my.fancy.package.app.from.uninstall" to quit'])
#
# Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', with_zap.staged_path/'MyFancyPkg'/'FancyUninstaller.tool', '--please'])
# Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', with_zap.staged_path.join('MyFancyPkg','FancyUninstaller.tool'), '--please'])
# Cask::FakeSystemCommand.expects_command(['/usr/bin/sudo', '-E', '--', '/bin/rm', '-rf', '--',
# Pathname.new('~/Library/Preferences/my.fancy.app.plist').expand_path])
#
Expand Down
Loading

0 comments on commit be4f975

Please sign in to comment.