Class: Cask::Artifact::AbstractArtifact Abstract Private
- Extended by:
- T::Helpers, Utils::Output::Mixin
- Includes:
- Comparable, Utils::Output::Mixin
- Defined in:
- cask/artifact/abstract_artifact.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.
It cannot be directly instantiated. Subclasses must implement the abstract
methods below.
Abstract superclass for all artifacts.
Direct Known Subclasses
AbstractFlightBlock, AbstractUninstall, Installer, Pkg, Relocated, StageOnly
Instance Attribute Summary collapse
- #cask ⇒ Object readonly private
Class Method Summary collapse
- .dirmethod ⇒ Object private
- .dsl_key ⇒ Object private
- .english_article ⇒ Object private
- .english_name ⇒ Object private
- .read_script_arguments(arguments, stanza, default_arguments = {}, override_arguments = {}, key = nil) ⇒ Object private
Instance Method Summary collapse
- #config ⇒ Object private
-
#initialize(cask, *dsl_args) ⇒ AbstractArtifact
constructor
private
A new instance of AbstractArtifact.
- #sort_order ⇒ Object private
- #staged_path_join_executable(path) ⇒ Object private
- #summarize ⇒ String abstract private
- #to_args ⇒ Object private
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
#initialize(cask, *dsl_args) ⇒ AbstractArtifact
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.
Returns a new instance of AbstractArtifact.
145 146 147 148 149 150 151 152 153 |
# File 'cask/artifact/abstract_artifact.rb', line 145 def initialize(cask, *dsl_args) @cask = cask @dirmethod = nil @dsl_args = dsl_args.deep_dup @dsl_key = nil @english_article = nil @english_name = nil @sort_order = nil end |
Instance Attribute Details
#cask ⇒ Object (readonly)
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.
143 144 145 |
# File 'cask/artifact/abstract_artifact.rb', line 143 def cask @cask end |
Class Method Details
.dirmethod ⇒ 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.
31 32 33 |
# File 'cask/artifact/abstract_artifact.rb', line 31 def self.dirmethod @dirmethod ||= :"#{dsl_key}dir" end |
.dsl_key ⇒ 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.
27 28 29 |
# File 'cask/artifact/abstract_artifact.rb', line 27 def self.dsl_key @dsl_key ||= T.must(name).sub(/^.*:/, "").gsub(/(.)([A-Z])/, '\1_\2').downcase.to_sym end |
.english_article ⇒ 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.
23 24 25 |
# File 'cask/artifact/abstract_artifact.rb', line 23 def self.english_article @english_article ||= /^[aeiou]/i.match?(english_name) ? "an" : "a" end |
.english_name ⇒ 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.
19 20 21 |
# File 'cask/artifact/abstract_artifact.rb', line 19 def self.english_name @english_name ||= T.must(name).sub(/^.*:/, "").gsub(/(.)([A-Z])/, '\1 \2') end |
.read_script_arguments(arguments, stanza, default_arguments = {}, override_arguments = {}, key = nil) ⇒ 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.
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.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'cask/artifact/abstract_artifact.rb', line 104 def self.read_script_arguments(arguments, stanza, default_arguments = {}, override_arguments = {}, key = nil) # TODO: when stanza names are harmonized with class names, # stanza may not be needed as an explicit argument description = key ? "#{stanza} #{key.inspect}" : stanza.to_s # backward-compatible string value arguments = if arguments.is_a?(String) { executable: arguments } else # Avoid mutating the original argument arguments.dup end # key sanity permitted_keys = [:args, :input, :executable, :must_succeed, :sudo, :print_stdout, :print_stderr] unknown_keys = arguments.keys - permitted_keys unless unknown_keys.empty? opoo "Unknown arguments to #{description} -- " \ "#{unknown_keys.inspect} (ignored). Running " \ "`brew update; brew cleanup` will likely fix it." end arguments.select! { |k| permitted_keys.include?(k) } # key warnings override_keys = override_arguments.keys ignored_keys = arguments.keys & override_keys unless ignored_keys.empty? onoe "Some arguments to #{description} will be ignored -- :#{unknown_keys.inspect} (overridden)." end # extract executable executable = arguments.key?(:executable) ? arguments.delete(:executable) : nil arguments = default_arguments.merge arguments arguments.merge! override_arguments [executable, arguments] end |
Instance Method Details
#config ⇒ 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.
155 156 157 |
# File 'cask/artifact/abstract_artifact.rb', line 155 def config cask.config end |
#sort_order ⇒ 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.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'cask/artifact/abstract_artifact.rb', line 57 def sort_order @sort_order ||= [ PreflightBlock, # The `uninstall` stanza should be run first, as it may # depend on other artifacts still being installed. Uninstall, Installer, # `pkg` should be run before `binary`, so # targets are created prior to linking. # `pkg` should be run before `app`, since an `app` could # contain a nested installer (e.g. `wireshark`). Pkg, [ App, Suite, Artifact, Colorpicker, Prefpane, Qlplugin, Mdimporter, Dictionary, Font, Service, InputMethod, InternetPlugin, KeyboardLayout, AudioUnitPlugin, VstPlugin, Vst3Plugin, ScreenSaver, ], Binary, Manpage, PostflightBlock, Zap, ].each_with_index.flat_map { |classes, i| Array(classes).map { |c| [c, i] } }.to_h end |
#staged_path_join_executable(path) ⇒ 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.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'cask/artifact/abstract_artifact.rb', line 38 def staged_path_join_executable(path) path = Pathname(path) path = path. if path.to_s.start_with?("~") absolute_path = if path.absolute? path else cask.staged_path.join(path) end FileUtils.chmod "+x", absolute_path if absolute_path.exist? && !absolute_path.executable? if absolute_path.exist? absolute_path else path end end |
#summarize ⇒ String
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.
36 |
# File 'cask/artifact/abstract_artifact.rb', line 36 def summarize; end |
#to_args ⇒ 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.
164 165 166 |
# File 'cask/artifact/abstract_artifact.rb', line 164 def to_args @dsl_args.compact_blank end |