diff --git a/Library/Homebrew/cask/lib/hbc/artifact/base.rb b/Library/Homebrew/cask/lib/hbc/artifact/base.rb index b53c13f08ed12004bac2bc12da763e0ab9b6d05a..d925ff340e3a2b76b4011ee6b799253c4df3ab03 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/base.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/base.rb @@ -27,10 +27,6 @@ module Hbc attr_reader :force - def zap_phase - odebug "Nothing to do. The #{self.class.artifact_name} artifact has no zap phase." - end - # TODO: this sort of logic would make more sense in dsl.rb, or a # constructor called from dsl.rb, so long as that isn't slow. def self.read_script_arguments(arguments, stanza, default_arguments = {}, override_arguments = {}, key = nil) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/installer.rb b/Library/Homebrew/cask/lib/hbc/artifact/installer.rb index b64b00fe3d6a2789a7aaf987864d2642a0605f95..55e8d38c03b77bfbcc9dc18f5fa125383f37a959 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/installer.rb @@ -3,16 +3,6 @@ require "hbc/artifact/base" module Hbc module Artifact class Installer < Base - # TODO: for backward compatibility, removeme - def install - install_phase - end - - # TODO: for backward compatibility, removeme - def uninstall - uninstall_phase - end - def install_phase @cask.artifacts[self.class.artifact_dsl_key].each do |artifact| if artifact.manual @@ -36,10 +26,6 @@ module Hbc end end end - - def uninstall_phase - odebug "Nothing to do. The #{self.class.artifact_dsl_key} artifact has no uninstall phase." - end end end end diff --git a/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb b/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb index 1076407972b2dc483c259e521efa0967a5daf770..45f23fe37059ee7c3bb2f334e97983645935b748 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/nested_container.rb @@ -7,10 +7,6 @@ module Hbc @cask.artifacts[:nested_container].each { |container| extract(container) } end - def uninstall_phase - # no need to take action; is removed after extraction - end - def extract(container_relative_path) source = @cask.staged_path.join(container_relative_path) container = Container.for_path(source, @command) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb index 0569d2a86e3a2c2f396a5938c00166f0846d9685..6d6362d46d9bd7537a7d00f95ef9a4989ecbf986 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb @@ -36,10 +36,6 @@ module Hbc @cask.artifacts[:pkg].each { |pkg_description| run_installer(pkg_description) } end - def uninstall_phase - # Do nothing. Must be handled explicitly by a separate :uninstall stanza. - end - def run_installer(pkg_description) load_pkg_description pkg_description ohai "Running installer for #{@cask}; your password may be necessary." diff --git a/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb b/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb index 594c5bef973945f37a87075cbb4bbebd6994690a..1122c1d02db66bb874ef1880449ccd1f60ea4f67 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb @@ -6,14 +6,6 @@ module Hbc def self.artifact_dsl_key :stage_only end - - def install_phase - # do nothing - end - - def uninstall_phase - # do nothing - end end end end diff --git a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb index ccb06a9ab01ef0a7294335451621d198c50e56cb..e18e9c31151de8307335d5dd45bec42cf15a8a72 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/uninstall_base.rb @@ -54,15 +54,11 @@ module Hbc path_strings - undeletable end - def install_phase - odebug "Nothing to do. The uninstall artifact has no install phase." - end - def uninstall_phase dispatch_uninstall_directives end - def dispatch_uninstall_directives(expand_tilde = true) + def dispatch_uninstall_directives(expand_tilde: true) directives_set = @cask.artifacts[stanza] ohai "Running #{stanza} process for #{@cask}; your password may be necessary" diff --git a/Library/Homebrew/cask/lib/hbc/artifact/zap.rb b/Library/Homebrew/cask/lib/hbc/artifact/zap.rb index 503ea35c49dbf40b3008b036c545893bcb7f4194..b31e2ef11abd2a06329bb0c6582a0b33e705bb7d 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/zap.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/zap.rb @@ -3,17 +3,8 @@ require "hbc/artifact/uninstall_base" module Hbc module Artifact class Zap < UninstallBase - def install_phase - odebug "Nothing to do. The zap artifact has no install phase." - end - def uninstall_phase - odebug "Nothing to do. The zap artifact has no uninstall phase." - end - - def zap_phase - expand_tilde = true - dispatch_uninstall_directives(expand_tilde) + dispatch_uninstall_directives(expand_tilde: true) end end end diff --git a/Library/Homebrew/cask/lib/hbc/installer.rb b/Library/Homebrew/cask/lib/hbc/installer.rb index 465011735e01677e454f6bde78fb0aabaa014d3d..28f67e5fd0d220e33eba3d3dc0631dfe6fa25778 100644 --- a/Library/Homebrew/cask/lib/hbc/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/installer.rb @@ -140,15 +140,18 @@ module Hbc odebug "#{artifacts.length} artifact/s defined", artifacts artifacts.each do |artifact| + artifact = artifact.new(@cask, options) + next unless artifact.respond_to?(:install_phase) odebug "Installing artifact of class #{artifact}" - artifact.new(@cask, options).install_phase + artifact.install_phase already_installed_artifacts.unshift(artifact) end rescue StandardError => e begin already_installed_artifacts.each do |artifact| + next unless artifact.respond_to?(:uninstall_phase) odebug "Reverting installation of artifact of class #{artifact}" - artifact.new(@cask, options).uninstall_phase + artifact.uninstall_phase end ensure purge_versioned_files @@ -319,9 +322,11 @@ module Hbc artifacts = Artifact.for_cask(@cask) odebug "#{artifacts.length} artifact/s defined", artifacts artifacts.each do |artifact| - odebug "Un-installing artifact of class #{artifact}" options = { command: @command, force: force } - artifact.new(@cask, options).uninstall_phase + artifact = artifact.new(@cask, options) + next unless artifact.respond_to?(:uninstall_phase) + odebug "Un-installing artifact of class #{artifact}" + artifact.uninstall_phase end end @@ -330,7 +335,7 @@ module Hbc uninstall_artifacts if Artifact::Zap.me?(@cask) ohai "Dispatching zap stanza" - Artifact::Zap.new(@cask, command: @command).zap_phase + Artifact::Zap.new(@cask, command: @command).uninstall_phase else opoo "No zap stanza present for Cask '#{@cask}'" end diff --git a/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb b/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb index a77fb0a079f86afd617ba0f89ea1e8fc1d842bc8..b054290ce35e5861f4f8b8922cc9c8683821940b 100644 --- a/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/pkg_test.rb @@ -21,16 +21,6 @@ describe Hbc::Artifact::Pkg do end end - describe "uninstall_phase" do - it "does nothing, because the uninstall_phase method is a no-op" do - pkg = Hbc::Artifact::Pkg.new(@cask, - command: Hbc::FakeSystemCommand) - shutup do - pkg.uninstall_phase - end - end - end - describe "choices" do before do @cask = Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-choices.rb") diff --git a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb b/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb index 3fb6791964a8a86f78d8db9820d2e8065d3ae03a..464cad34543f336ad61fa826a584639a78e67b63 100644 --- a/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/uninstall_test.rb @@ -13,28 +13,12 @@ describe Hbc::Artifact::Uninstall do end end - describe "install_phase" do - it "does nothing, because the install_phase method is a no-op" do - shutup do - uninstall_artifact.install_phase - end - end - end - - describe "zap_phase" do - it "does nothing, because the zap_phase method is a no-op" do - shutup do - uninstall_artifact.zap_phase - end - end - end - describe "uninstall_phase" do - subject do + subject { shutup do uninstall_artifact.uninstall_phase end - end + } describe "when using launchctl" do let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-uninstall-launchctl.rb") } diff --git a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb b/Library/Homebrew/cask/test/cask/artifact/zap_test.rb index 0ebd9b304dc52aa2ffad19a38a5a2fe5e2bab6a6..ea546728b55cb96b3a2257c9fe2e36c0129535e1 100644 --- a/Library/Homebrew/cask/test/cask/artifact/zap_test.rb +++ b/Library/Homebrew/cask/test/cask/artifact/zap_test.rb @@ -14,28 +14,12 @@ describe Hbc::Artifact::Zap do end end - describe "install_phase" do - it "does nothing, because the install_phase method is a no-op" do - shutup do - zap_artifact.install_phase - end - end - end - describe "uninstall_phase" do - it "does nothing, because the uninstall_phase method is a no-op" do + subject { shutup do zap_artifact.uninstall_phase end - end - end - - describe "zap_phase" do - subject do - shutup do - zap_artifact.zap_phase - end - end + } describe "when using launchctl" do let(:cask) { Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-zap-launchctl.rb") }