Class: Cask::Artifact::Installer Private
- Inherits:
-
AbstractArtifact
- Object
- AbstractArtifact
- Cask::Artifact::Installer
- Defined in:
- cask/artifact/installer.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 installer stanza.
Constant Summary collapse
- VALID_KEYS =
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.
T.let(Set.new([ :manual, :script, ]).freeze, T::Set[Symbol])
Constants inherited from AbstractArtifact
AbstractArtifact::DirectivesType
Instance Attribute Summary collapse
- #args ⇒ Hash{Symbol => T.untyped} readonly private
- #manual_install ⇒ Boolean readonly private
- #path ⇒ Pathname readonly private
Attributes inherited from AbstractArtifact
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(cask, **args) ⇒ void constructor private
- #install_phase(command: SystemCommand, **_options) ⇒ void private
- #summarize ⇒ String private
- #to_h ⇒ Hash{Symbol => T.untyped} private
Methods inherited from AbstractArtifact
#config, dirmethod, dsl_key, english_article, english_name, read_script_arguments, #sort_order, #staged_path_join_executable, #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_deprecated, #pretty_disabled, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled
Constructor Details
#initialize(cask, **args) ⇒ void
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.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'cask/artifact/installer.rb', line 74 def initialize(cask, **args) super if args.key?(:manual) @path = T.let(Pathname(args[:manual]), Pathname) @args = T.let({}, T::Hash[Symbol, T.untyped]) @manual_install = T.let(true, T::Boolean) else script_path, script_args = self.class.read_script_arguments( args[:script], self.class.dsl_key.to_s, { must_succeed: true, sudo: false }, print_stdout: true ) raise CaskInvalidError.new(cask, "#{self.class.dsl_key} missing executable") if script_path.nil? @path = T.let(Pathname(script_path), Pathname) @args = T.let(script_args, T::Hash[Symbol, T.untyped]) @manual_install = T.let(false, T::Boolean) end end |
Instance Attribute Details
#args ⇒ Hash{Symbol => T.untyped} (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.
68 69 70 |
# File 'cask/artifact/installer.rb', line 68 def args @args end |
#manual_install ⇒ Boolean (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.
71 72 73 |
# File 'cask/artifact/installer.rb', line 71 def manual_install @manual_install end |
#path ⇒ Pathname (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.
65 66 67 |
# File 'cask/artifact/installer.rb', line 65 def path @path end |
Class Method Details
.from_args(cask, **args) ⇒ T.attached_class
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.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'cask/artifact/installer.rb', line 40 def self.from_args(cask, **args) raise CaskInvalidError.new(cask, "'installer' stanza requires an argument.") if args.empty? if args.key?(:script) && !args[:script].respond_to?(:key?) if args.key?(:executable) raise CaskInvalidError.new(cask, "'installer' stanza gave arguments for both :script and :executable.") end args[:executable] = args[:script] args.delete(:script) args = { script: args } end if args.keys.count != 1 raise CaskInvalidError.new( cask, "invalid 'installer' stanza: Only one of #{VALID_KEYS.inspect} is permitted.", ) end args.assert_valid_keys(*VALID_KEYS) new(cask, **args) end |
Instance Method Details
#install_phase(command: SystemCommand, **_options) ⇒ void
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 method returns an undefined value.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'cask/artifact/installer.rb', line 17 def install_phase(command: SystemCommand, **) if manual_install puts <<~EOS Cask #{cask} only provides a manual installer. To run it and complete the installation: open #{cask.staged_path.join(path).to_s.shellescape} EOS else ohai "Running #{self.class.dsl_key} script '#{path}'" executable_path = staged_path_join_executable(path) command.run!( executable_path, **args, env: { "PATH" => PATH.new( HOMEBREW_PREFIX/"bin", HOMEBREW_PREFIX/"sbin", ENV.fetch("PATH") ) }, reset_uid: !args[:sudo], ) 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.
94 |
# File 'cask/artifact/installer.rb', line 94 def summarize = path.to_s |
#to_h ⇒ Hash{Symbol => T.untyped}
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.
97 98 99 100 101 |
# File 'cask/artifact/installer.rb', line 97 def to_h { path: }.tap do |h| h[:args] = args unless manual_install end end |