Class: Cask::Artifact::Uninstall Private

Inherits:
AbstractUninstall show all
Defined in:
cask/artifact/uninstall.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Artifact corresponding to the uninstall stanza.

Constant Summary collapse

UPGRADE_REINSTALL_SKIP_DIRECTIVES =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

[:quit, :signal].freeze

Constants inherited from AbstractUninstall

AbstractUninstall::METADATA_KEYS, AbstractUninstall::ORDERED_DIRECTIVES

Instance Attribute Summary

Attributes inherited from AbstractUninstall

#directives

Attributes inherited from AbstractArtifact

#cask

Instance Method Summary collapse

Methods inherited from AbstractUninstall

from_args, #initialize, #summarize, #to_h

Methods included from SystemCommand::Mixin

#system_command, #system_command!

Methods included from OS::Mac::Cask::Artifact::AbstractUninstall

#undeletable?

Methods inherited from AbstractArtifact

#config, dirmethod, dsl_key, english_article, english_name, #initialize, read_script_arguments, #sort_order, #staged_path_join_executable, #summarize, #to_args

Methods included from Utils::Output::Mixin

#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled

Constructor Details

This class inherits a constructor from Cask::Artifact::AbstractUninstall

Instance Method Details

#post_uninstall_phase(**options) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



45
46
47
# File 'cask/artifact/uninstall.rb', line 45

def post_uninstall_phase(**options)
  dispatch_uninstall_directive(:rmdir, **options)
end

#uninstall_phase(**options) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'cask/artifact/uninstall.rb', line 12

def uninstall_phase(**options)
  upgrade   = options.fetch(:upgrade, false)
  reinstall = options.fetch(:reinstall, false)

  raw_on_upgrade = directives[:on_upgrade]
  on_upgrade_syms =
    case raw_on_upgrade
    when Symbol
      [raw_on_upgrade]
    when Array
      raw_on_upgrade.map(&:to_sym)
    else
      []
    end
  on_upgrade_set = on_upgrade_syms.to_set

  filtered_directives = ORDERED_DIRECTIVES.filter do |directive_sym|
    next false if directive_sym == :rmdir

    if (upgrade || reinstall) &&
       UPGRADE_REINSTALL_SKIP_DIRECTIVES.include?(directive_sym) &&
       on_upgrade_set.exclude?(directive_sym)
      next false
    end

    true
  end

  filtered_directives.each do |directive_sym|
    dispatch_uninstall_directive(directive_sym, **options)
  end
end