Module: Homebrew::Bundle::CaskInstaller Private
- 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
- .installed_casks ⇒ Object private
- .outdated_casks ⇒ Object private
- .preinstall(name, no_upgrade: false, verbose: false, **options) ⇒ Object private
- .reset! ⇒ Object private
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.
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'bundle/cask_installer.rb', line 90 def self.cask_in_array?(cask, array) return true if array.include?(cask) return true if array.include?(cask.split("/").last) require "bundle/cask_dumper" old_names = Homebrew::Bundle::CaskDumper.cask_oldnames old_name = old_names[cask] old_name ||= old_names[cask.split("/").last] return true if old_name && array.include?(old_name) false 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.
103 104 105 |
# File 'bundle/cask_installer.rb', line 103 def self.cask_installed?(cask) cask_in_array?(cask, installed_casks) 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.
83 84 85 86 87 88 |
# File 'bundle/cask_installer.rb', line 83 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.
107 108 109 |
# File 'bundle/cask_installer.rb', line 107 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.
30 31 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 |
# File 'bundle/cask_installer.rb', line 30 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 installed_casks.include?(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 |
.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.
111 112 113 114 |
# File 'bundle/cask_installer.rb', line 111 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.
116 117 118 119 |
# File 'bundle/cask_installer.rb', line 116 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.
21 22 23 24 25 26 27 28 |
# File 'bundle/cask_installer.rb', line 21 def self.preinstall(name, no_upgrade: false, verbose: false, **) if installed_casks.include?(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.
7 8 9 10 |
# File 'bundle/cask_installer.rb', line 7 def self.reset! @installed_casks = nil @outdated_casks = nil end |