Module: Homebrew::Bundle::CaskInstaller Private
- Extended by:
- Utils::Output::Mixin
- Defined in:
- bundle/cask_installer.rb
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Class Method Summary collapse
- .cask_in_array?(cask, array) ⇒ Boolean private
- .cask_installed?(cask) ⇒ Boolean private
- .cask_installed_and_up_to_date?(cask, no_upgrade: false) ⇒ Boolean private
- .cask_upgradable?(cask) ⇒ Boolean private
- .install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options) ⇒ Object private
- .installable_or_upgradable?(name, no_upgrade: false, **options) ⇒ Boolean private
- .installed_casks ⇒ Object private
- .outdated_casks ⇒ Object private
- .preinstall!(name, no_upgrade: false, verbose: false, **options) ⇒ Object private
- .reset! ⇒ 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
Class Method Details
.cask_in_array?(cask, array) ⇒ Boolean
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.
96 97 98 99 100 |
# File 'bundle/cask_installer.rb', line 96 def self.cask_in_array?(cask, array) return true if array.include?(cask) array.include?(cask.split("/").last) end |
.cask_installed?(cask) ⇒ Boolean
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.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'bundle/cask_installer.rb', line 102 def self.cask_installed?(cask) return true if cask_in_array?(cask, installed_casks) require "bundle/cask_dumper" old_names = Homebrew::Bundle::CaskDumper.cask_oldnames old_name = old_names[cask] old_name ||= old_names[cask.split("/").last] return false unless old_name return false unless cask_in_array?(old_name, installed_casks) opoo "#{cask} was renamed to #{old_name}" true end |
.cask_installed_and_up_to_date?(cask, no_upgrade: false) ⇒ Boolean
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.
89 90 91 92 93 94 |
# File 'bundle/cask_installer.rb', line 89 def self.cask_installed_and_up_to_date?(cask, no_upgrade: false) return false unless cask_installed?(cask) return true if no_upgrade !cask_upgradable?(cask) end |
.cask_upgradable?(cask) ⇒ Boolean
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.
117 118 119 |
# File 'bundle/cask_installer.rb', line 117 def self.cask_upgradable?(cask) cask_in_array?(cask, outdated_casks) end |
.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **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.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'bundle/cask_installer.rb', line 32 def self.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **) return true unless preinstall full_name = .fetch(:full_name, name) install_result = if cask_installed?(name) && upgrading?(no_upgrade, name, ) status = "#{[:greedy] ? "may not be" : "not"} up-to-date" puts "Upgrading #{name} cask. It is installed but #{status}." if verbose Bundle.brew("upgrade", "--cask", full_name, verbose:) else args = .fetch(:args, []).filter_map do |k, v| case v when TrueClass "--#{k}" when FalseClass, NilClass nil else "--#{k}=#{v}" end end args << "--force" if force args << "--adopt" unless args.include?("--force") args.uniq! with_args = " with #{args.join(" ")}" if args.present? puts "Installing #{name} cask#{with_args}. It is not currently installed." if verbose if Bundle.brew("install", "--cask", full_name, *args, verbose:) installed_casks << name true else false end end result = install_result if cask_installed?(name) postinstall_result = postinstall_change_state!(name:, options:, verbose:) result &&= postinstall_result end result end |
.installable_or_upgradable?(name, no_upgrade: false, **options) ⇒ Boolean
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.
77 78 79 |
# File 'bundle/cask_installer.rb', line 77 def self.installable_or_upgradable?(name, no_upgrade: false, **) !cask_installed?(name) || upgrading?(no_upgrade, name, ) end |
.installed_casks ⇒ 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.
121 122 123 124 |
# File 'bundle/cask_installer.rb', line 121 def self.installed_casks require "bundle/cask_dumper" @installed_casks ||= Homebrew::Bundle::CaskDumper.cask_names end |
.outdated_casks ⇒ 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.
126 127 128 129 |
# File 'bundle/cask_installer.rb', line 126 def self.outdated_casks require "bundle/cask_dumper" @outdated_casks ||= Homebrew::Bundle::CaskDumper.outdated_cask_names end |
.preinstall!(name, no_upgrade: false, verbose: false, **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.
23 24 25 26 27 28 29 30 |
# File 'bundle/cask_installer.rb', line 23 def self.preinstall!(name, no_upgrade: false, verbose: false, **) if cask_installed?(name) && !upgrading?(no_upgrade, name, ) puts "Skipping install of #{name} cask. It is already installed." if verbose return false end true end |
.reset! ⇒ 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.
9 10 11 12 |
# File 'bundle/cask_installer.rb', line 9 def self.reset! @installed_casks = nil @outdated_casks = nil end |