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

#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