Module: Homebrew::Livecheck::SkipConditions Private
- Includes:
- Kernel
- Defined in:
- livecheck/skip_conditions.rb,
livecheck/livecheck.rbi
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/resource 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.
T.let([ :package_or_resource_skip, :formula_head_only, :formula_deprecated, :formula_disabled, :formula_versioned, ].freeze, T::Array[Symbol])
- 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.
T.let([ :package_or_resource_skip, :cask_deprecated, :cask_disabled, :cask_extract_plist, :cask_version_latest, :cask_url_unversioned, ].freeze, T::Array[Symbol])
- RESOURCE_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 resources.
T.let([ :package_or_resource_skip, ].freeze, T::Array[Symbol])
Constants included from Kernel
Kernel::IGNORE_INTERRUPTS_MUTEX
Class Method Summary collapse
- .cask_deprecated(cask, livecheckable, full_name: false, verbose: false) ⇒ Hash{Symbol => T.untyped} private
- .cask_disabled(cask, livecheckable, full_name: false, verbose: false) ⇒ Hash{Symbol => T.untyped} private
- .cask_extract_plist(cask, _livecheckable, full_name: false, verbose: false, extract_plist: false) ⇒ Hash{Symbol => T.untyped} private
- .cask_url_unversioned(cask, livecheckable, full_name: false, verbose: false) ⇒ Hash{Symbol => T.untyped} private
- .cask_version_latest(cask, livecheckable, full_name: false, verbose: false) ⇒ Hash{Symbol => T.untyped} private
- .formula_deprecated(formula, livecheckable, full_name: false, verbose: false) ⇒ Hash{Symbol => T.untyped} private
- .formula_disabled(formula, livecheckable, full_name: false, verbose: false) ⇒ Hash{Symbol => T.untyped} private
- .formula_head_only(formula, _livecheckable, full_name: false, verbose: false) ⇒ Hash{Symbol => T.untyped} private
- .formula_versioned(formula, livecheckable, full_name: false, verbose: false) ⇒ Hash{Symbol => T.untyped} private
- .package_or_resource_skip(package_or_resource, livecheckable, full_name: false, verbose: false) ⇒ Hash{Symbol => T.untyped} private
-
.print_skip_information(skip_hash) ⇒ void
private
Prints default livecheck output in relation to skip conditions.
-
.referenced_skip_information(livecheck_package_or_resource, original_package_or_resource_name, full_name: false, verbose: false, extract_plist: true) ⇒ Hash{Symbol => T.untyped}?
private
Skip conditions for formulae/casks/resources referenced in a
livecheck
block are treated differently than normal. -
.skip_information(package_or_resource, full_name: false, verbose: false, extract_plist: true) ⇒ Hash{Symbol => T.untyped}
private
If a formula/cask/resource should be skipped, we return a hash from
Livecheck#status_hash
, which contains astatus
type and sometimes errormessages
.
Methods included from Kernel
#disk_usage_readable, #ensure_executable!, #ensure_formula_installed!, #exec_browser, #exec_editor, #ignore_interrupts, #interactive_shell, #number_readable, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #paths, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled, #quiet_system, #redact_secrets, #redirect_stdout, #require?, #safe_system, #tap_and_name_comparison, #truncate_text_to_approximate_size, #which, #which_all, #which_editor, #with_custom_locale, #with_env, #with_homebrew_path
Class Method Details
.cask_deprecated(cask, livecheckable, full_name: false, verbose: false) ⇒ 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.
118 119 120 121 122 |
# File 'livecheck/skip_conditions.rb', line 118 def cask_deprecated(cask, livecheckable, full_name: false, verbose: false) return {} if !cask.deprecated? || livecheckable Livecheck.status_hash(cask, "deprecated", full_name:, verbose:) end |
.cask_disabled(cask, livecheckable, full_name: false, verbose: false) ⇒ 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.
132 133 134 135 136 |
# File 'livecheck/skip_conditions.rb', line 132 def cask_disabled(cask, livecheckable, full_name: false, verbose: false) return {} if !cask.disabled? || livecheckable Livecheck.status_hash(cask, "disabled", full_name:, verbose:) end |
.cask_extract_plist(cask, _livecheckable, full_name: false, verbose: false, extract_plist: false) ⇒ 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.
147 148 149 150 151 152 153 154 155 156 157 |
# File 'livecheck/skip_conditions.rb', line 147 def cask_extract_plist(cask, _livecheckable, full_name: false, verbose: false, extract_plist: false) return {} if extract_plist || cask.livecheck.strategy != :extract_plist Livecheck.status_hash( cask, "skipped", ["Use `--extract-plist` to enable checking multiple casks with ExtractPlist strategy"], full_name:, verbose:, ) end |
.cask_url_unversioned(cask, livecheckable, full_name: false, verbose: false) ⇒ 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.
181 182 183 184 185 |
# File 'livecheck/skip_conditions.rb', line 181 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:, verbose:) end |
.cask_version_latest(cask, livecheckable, full_name: false, verbose: false) ⇒ 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.
167 168 169 170 171 |
# File 'livecheck/skip_conditions.rb', line 167 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:, verbose:) end |
.formula_deprecated(formula, livecheckable, full_name: false, verbose: false) ⇒ 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.
76 77 78 79 80 |
# File 'livecheck/skip_conditions.rb', line 76 def formula_deprecated(formula, livecheckable, full_name: false, verbose: false) return {} if !formula.deprecated? || livecheckable Livecheck.status_hash(formula, "deprecated", full_name:, verbose:) end |
.formula_disabled(formula, livecheckable, full_name: false, verbose: false) ⇒ 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.
90 91 92 93 94 |
# File 'livecheck/skip_conditions.rb', line 90 def formula_disabled(formula, livecheckable, full_name: false, verbose: false) return {} if !formula.disabled? || livecheckable Livecheck.status_hash(formula, "disabled", full_name:, verbose:) end |
.formula_head_only(formula, _livecheckable, full_name: false, verbose: false) ⇒ 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.
56 57 58 59 60 61 62 63 64 65 66 |
# File 'livecheck/skip_conditions.rb', line 56 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:, verbose:, ) end |
.formula_versioned(formula, livecheckable, full_name: false, verbose: false) ⇒ 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.
104 105 106 107 108 |
# File 'livecheck/skip_conditions.rb', line 104 def formula_versioned(formula, livecheckable, full_name: false, verbose: false) return {} if !formula.versioned_formula? || livecheckable Livecheck.status_hash(formula, "versioned", full_name:, verbose:) end |
.package_or_resource_skip(package_or_resource, livecheckable, full_name: false, verbose: false) ⇒ 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.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'livecheck/skip_conditions.rb', line 19 def package_or_resource_skip(package_or_resource, livecheckable, full_name: false, verbose: false) formula = package_or_resource if package_or_resource.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 package_or_resource.livecheck.skip_msg.present? package_or_resource.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 !package_or_resource.livecheck.skip? && .blank? = ? [] : nil Livecheck.status_hash(package_or_resource, "skipped", , full_name:, 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.
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'livecheck/skip_conditions.rb', line 302 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] elsif skip_hash[:resource].is_a?(String) " #{skip_hash[:resource]}" 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 |
.referenced_skip_information(livecheck_package_or_resource, original_package_or_resource_name, full_name: false, verbose: false, extract_plist: true) ⇒ 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.
Skip conditions for formulae/casks/resources referenced in a livecheck
block
are treated differently than normal. We only respect certain skip
conditions (returning the related hash) and others are treated as
errors.
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'livecheck/skip_conditions.rb', line 260 def referenced_skip_information( livecheck_package_or_resource, original_package_or_resource_name, full_name: false, verbose: false, extract_plist: true ) skip_info = SkipConditions.skip_information( livecheck_package_or_resource, full_name:, verbose:, extract_plist:, ) return if skip_info.blank? referenced_name = Livecheck.package_or_resource_name(livecheck_package_or_resource, full_name:) referenced_type = case livecheck_package_or_resource when Formula :formula when Cask::Cask :cask when Resource :resource end if skip_info[:status] != "error" && !(skip_info[:status] == "skipped" && livecheck_package_or_resource.livecheck.skip?) error_msg_end = if skip_info[:status] == "skipped" "automatically skipped" else "skipped as #{skip_info[:status]}" end raise "Referenced #{referenced_type} (#{referenced_name}) is #{error_msg_end}" end skip_info[referenced_type] = original_package_or_resource_name skip_info end |
.skip_information(package_or_resource, full_name: false, verbose: false, extract_plist: true) ⇒ 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.
If a formula/cask/resource should be skipped, we return a hash from
Livecheck#status_hash
, which contains a status
type and sometimes
error messages
.
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'livecheck/skip_conditions.rb', line 222 def skip_information(package_or_resource, full_name: false, verbose: false, extract_plist: true) livecheckable = package_or_resource.livecheckable? checks = case package_or_resource when Formula FORMULA_CHECKS when Cask::Cask CASK_CHECKS when Resource RESOURCE_CHECKS end checks.each do |method_name| skip_hash = case method_name when :cask_extract_plist send(method_name, package_or_resource, livecheckable, full_name:, verbose:, extract_plist:) else send(method_name, package_or_resource, livecheckable, full_name:, verbose:) end return skip_hash if skip_hash.present? end {} end |