Module: Homebrew::Livecheck::SkipConditions Private
- Extended by:
- T::Sig
- Defined in:
- livecheck/skip_conditions.rb
Overview
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.
The Livecheck::SkipConditions
module primarily contains methods that
check for various formula/cask conditions where a check should be skipped.
Constant Summary collapse
- FORMULA_CHECKS =
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.
Skip conditions for formulae.
[ :formula_or_cask_skip, :formula_head_only, :formula_deprecated, :formula_disabled, :formula_versioned, ].freeze
- CASK_CHECKS =
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.
Skip conditions for casks.
[ :formula_or_cask_skip, :cask_discontinued, :cask_version_latest, :cask_url_unversioned, ].freeze
Class Method Summary collapse
-
.cask_discontinued(cask, livecheckable, full_name: false, verbose: false) ⇒ Hash
private
-
.cask_url_unversioned(cask, livecheckable, full_name: false, verbose: false) ⇒ Hash
private
-
.cask_version_latest(cask, livecheckable, full_name: false, verbose: false) ⇒ Hash
private
-
.formula_deprecated(formula, livecheckable, full_name: false, verbose: false) ⇒ Hash
private
-
.formula_disabled(formula, livecheckable, full_name: false, verbose: false) ⇒ Hash
private
-
.formula_head_only(formula, _livecheckable, full_name: false, verbose: false) ⇒ Hash
private
-
.formula_or_cask_skip(formula_or_cask, livecheckable, full_name: false, verbose: false) ⇒ Hash
private
-
.formula_versioned(formula, livecheckable, full_name: false, verbose: false) ⇒ Hash
private
-
.print_skip_information(skip_hash) ⇒ void
private
Prints default livecheck output in relation to skip conditions.
-
.skip_information(formula_or_cask, full_name: false, verbose: false) ⇒ Hash
private
If a formula/cask should be skipped, we return a hash from
Livecheck#status_hash
, which contains astatus
type and sometimes errormessages
.
Class Method Details
.cask_discontinued(cask, livecheckable, full_name: false, verbose: false) ⇒ Hash
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.
124 125 126 127 128 |
# File 'livecheck/skip_conditions.rb', line 124 def cask_discontinued(cask, livecheckable, full_name: false, verbose: false) return {} if !cask.discontinued? || livecheckable Livecheck.status_hash(cask, "discontinued", full_name: full_name, verbose: verbose) end |
.cask_url_unversioned(cask, livecheckable, full_name: false, verbose: false) ⇒ Hash
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.
152 153 154 155 156 |
# File 'livecheck/skip_conditions.rb', line 152 def cask_url_unversioned(cask, livecheckable, full_name: false, verbose: false) return {} if !(cask.present? && cask.url&.unversioned?) || livecheckable Livecheck.status_hash(cask, "unversioned", full_name: full_name, verbose: verbose) end |
.cask_version_latest(cask, livecheckable, full_name: false, verbose: false) ⇒ Hash
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.
138 139 140 141 142 |
# File 'livecheck/skip_conditions.rb', line 138 def cask_version_latest(cask, livecheckable, full_name: false, verbose: false) return {} if !(cask.present? && cask.version&.latest?) || livecheckable Livecheck.status_hash(cask, "latest", full_name: full_name, verbose: verbose) end |
.formula_deprecated(formula, livecheckable, full_name: false, verbose: false) ⇒ Hash
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.
82 83 84 85 86 |
# File 'livecheck/skip_conditions.rb', line 82 def formula_deprecated(formula, livecheckable, full_name: false, verbose: false) return {} if !formula.deprecated? || livecheckable Livecheck.status_hash(formula, "deprecated", full_name: full_name, verbose: verbose) end |
.formula_disabled(formula, livecheckable, full_name: false, verbose: false) ⇒ Hash
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 'livecheck/skip_conditions.rb', line 96 def formula_disabled(formula, livecheckable, full_name: false, verbose: false) return {} if !formula.disabled? || livecheckable Livecheck.status_hash(formula, "disabled", full_name: full_name, verbose: verbose) end |
.formula_head_only(formula, _livecheckable, full_name: false, verbose: false) ⇒ Hash
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.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'livecheck/skip_conditions.rb', line 62 def formula_head_only(formula, _livecheckable, full_name: false, verbose: false) return {} if !formula.head_only? || formula.any_version_installed? Livecheck.status_hash( formula, "error", ["HEAD only formula must be installed to be livecheckable"], full_name: full_name, verbose: verbose, ) end |
.formula_or_cask_skip(formula_or_cask, livecheckable, full_name: false, verbose: false) ⇒ Hash
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.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'livecheck/skip_conditions.rb', line 25 def formula_or_cask_skip(formula_or_cask, livecheckable, full_name: false, verbose: false) formula = formula_or_cask if formula_or_cask.is_a?(Formula) if (stable_url = formula&.stable&.url) stable_is_gist = stable_url.match?(%r{https?://gist\.github(?:usercontent)?\.com/}i) stable_from_google_code_archive = stable_url.match?( %r{https?://storage\.googleapis\.com/google-code-archive-downloads/}i, ) stable_from_internet_archive = stable_url.match?(%r{https?://web\.archive\.org/}i) end = if formula_or_cask.livecheck.skip_msg.present? formula_or_cask.livecheck.skip_msg elsif !livecheckable if stable_from_google_code_archive "Stable URL is from Google Code Archive" elsif stable_from_internet_archive "Stable URL is from Internet Archive" elsif stable_is_gist "Stable URL is a GitHub Gist" end end return {} if !formula_or_cask.livecheck.skip? && .blank? = ? [] : nil Livecheck.status_hash(formula_or_cask, "skipped", , full_name: full_name, verbose: verbose) end |
.formula_versioned(formula, livecheckable, full_name: false, verbose: false) ⇒ Hash
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.
110 111 112 113 114 |
# File 'livecheck/skip_conditions.rb', line 110 def formula_versioned(formula, livecheckable, full_name: false, verbose: false) return {} if !formula.versioned_formula? || livecheckable Livecheck.status_hash(formula, "versioned", full_name: full_name, verbose: verbose) end |
.print_skip_information(skip_hash) ⇒ 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.
Prints default livecheck output in relation to skip conditions.
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'livecheck/skip_conditions.rb', line 206 def print_skip_information(skip_hash) return unless skip_hash.is_a?(Hash) name = if skip_hash[:formula].is_a?(String) skip_hash[:formula] elsif skip_hash[:cask].is_a?(String) skip_hash[:cask] end return unless name if skip_hash[:messages].is_a?(Array) && skip_hash[:messages].count.positive? # TODO: Handle multiple messages, only if needed in the future if skip_hash[:status] == "skipped" puts "#{Tty.red}#{name}#{Tty.reset} : skipped - #{skip_hash[:messages][0]}" else puts "#{Tty.red}#{name}#{Tty.reset} : #{skip_hash[:messages][0]}" end elsif skip_hash[:status].present? puts "#{Tty.red}#{name}#{Tty.reset} : #{skip_hash[:status]}" end end |
.skip_information(formula_or_cask, full_name: false, verbose: false) ⇒ Hash
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.
If a formula/cask should be skipped, we return a hash from
Livecheck#status_hash
, which contains a status
type and sometimes
error messages
.
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'livecheck/skip_conditions.rb', line 185 def skip_information(formula_or_cask, full_name: false, verbose: false) livecheckable = formula_or_cask.livecheckable? checks = case formula_or_cask when Formula FORMULA_CHECKS when Cask::Cask CASK_CHECKS end return {} unless checks checks.each do |method_name| skip_hash = send(method_name, formula_or_cask, livecheckable, full_name: full_name, verbose: verbose) return skip_hash if skip_hash.present? end {} end |