Class: Cask::Artifact::AbstractUninstall

Inherits:
AbstractArtifact show all
Defined in:
brew/Library/Homebrew/cask/artifact/abstract_uninstall.rb

Direct Known Subclasses

Uninstall, Zap

Constant Summary collapse

ORDERED_DIRECTIVES =
[
  :early_script,
  :launchctl,
  :quit,
  :signal,
  :login_item,
  :kext,
  :script,
  :pkgutil,
  :delete,
  :trash,
  :rmdir,
].freeze
TRASH_SCRIPT =
(HOMEBREW_LIBRARY_PATH/"cask/utils/trash.swift").freeze

Instance Attribute Summary collapse

Attributes inherited from AbstractArtifact

#cask

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractArtifact

#<=>, #config, dirmethod, dsl_key, english_article, english_name, read_script_arguments, #staged_path_join_executable, #to_s

Methods included from Predicable

#attr_predicate

Constructor Details

#initialize(cask, directives) ⇒ AbstractUninstall

Returns a new instance of AbstractUninstall



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'brew/Library/Homebrew/cask/artifact/abstract_uninstall.rb', line 35

def initialize(cask, directives)
  directives.assert_valid_keys!(*ORDERED_DIRECTIVES)

  super(cask)
  directives[:signal] = [*directives[:signal]].flatten.each_slice(2).to_a
  @directives = directives

  return unless directives.key?(:kext)

  cask.caveats do
    kext
  end
end

Instance Attribute Details

#directivesObject (readonly)

Returns the value of attribute directives



33
34
35
# File 'brew/Library/Homebrew/cask/artifact/abstract_uninstall.rb', line 33

def directives
  @directives
end

Class Method Details

.from_args(cask, **directives) ⇒ Object



29
30
31
# File 'brew/Library/Homebrew/cask/artifact/abstract_uninstall.rb', line 29

def self.from_args(cask, **directives)
  new(cask, directives)
end

Instance Method Details

#summarizeObject



53
54
55
# File 'brew/Library/Homebrew/cask/artifact/abstract_uninstall.rb', line 53

def summarize
  to_h.flat_map { |key, val| [*val].map { |v| "#{key.inspect} => #{v.inspect}" } }.join(", ")
end

#to_hObject



49
50
51
# File 'brew/Library/Homebrew/cask/artifact/abstract_uninstall.rb', line 49

def to_h
  directives.to_h
end