Module: Homebrew::Livecheck::Output Private

Extended by:
T::Helpers
Included in:
Homebrew::Livecheck
Defined in:
livecheck/output.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.

Human-readable and structured livecheck results.

Instance Method Summary collapse

Instance Method Details

#report_error(package_or_resource, error, json: false, quiet: false, debug: false, full_name: false, verbose: false, ambiguous_cask: false) ⇒ Hash{Symbol => String, Array<String>, Hash{Symbol => 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.

Parameters:

  • package_or_resource (Formula, Cask::Cask, Resource)
  • error (StandardError)
  • json (Boolean) (defaults to: false)
  • quiet (Boolean) (defaults to: false)
  • debug (Boolean) (defaults to: false)
  • full_name (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)
  • ambiguous_cask (Boolean) (defaults to: false)

Returns:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'livecheck/output.rb', line 67

def report_error(package_or_resource, error, json: false, quiet: false, debug: false, full_name: false,
                 verbose: false, ambiguous_cask: false)
  return if quiet
  return status_hash(package_or_resource, "error", [error.to_s], full_name:, verbose:) if json

  name = package_or_resource_name(package_or_resource, full_name:)
  name += " (cask)" if ambiguous_cask
  onoe "#{Tty.blue}#{name}#{Tty.reset}: #{error}"
  if debug && !error.is_a?(Livecheck::Error)
    require "utils/backtrace"
    $stderr.puts Utils::Backtrace.clean(error)
  end
  nil
end

#status_hash(package_or_resource, status_str, messages = nil, 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.

Parameters:

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'livecheck/output.rb', line 21

def status_hash(package_or_resource, status_str, messages = nil, full_name: false, verbose: false)
  formula = package_or_resource if package_or_resource.is_a?(Formula)
  cask = package_or_resource if package_or_resource.is_a?(Cask::Cask)
  resource = package_or_resource if package_or_resource.is_a?(Resource)

  status_hash = {}
  if formula
    status_hash[:formula] = formula_name(formula, full_name:)
  elsif cask
    status_hash[:cask] = cask_name(cask, full_name:)
  elsif resource
    status_hash[:resource] = resource.name
  end
  status_hash[:status] = status_str
  status_hash[:messages] = messages if messages.is_a?(Array)

  status_hash[:meta] = {
    livecheck_defined: package_or_resource.livecheck_defined?,
  }
  status_hash[:meta][:head_only] = true if formula&.head_only?

  status_hash
end

#url_metadata(original_url:, url:, url_symbol:, strategy_url:, final_url:, url_options:) ⇒ Hash{Symbol => String, Symbol, Hash{Symbol => T.anything}}

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.

Parameters:

Returns:



50
51
52
53
54
55
56
57
58
59
# File 'livecheck/output.rb', line 50

def (original_url:, url:, url_symbol:, strategy_url:, final_url:, url_options:)
  {
    symbol:    url_symbol,
    original:  original_url,
    processed: (url if url != original_url),
    strategy:  (strategy_url if strategy_url.present? && strategy_url != url),
    final:     final_url,
    options:   url_options.presence,
  }.compact
end