Module: Homebrew::API::Versions Private

Extended by:
T::Sig
Defined in:
api/versions.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.

Helper functions for using the versions JSON API.

Class Method Summary collapse

Class Method Details

.casksObject

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.



18
19
20
21
# File 'api/versions.rb', line 18

def casks
  # The result is cached by Homebrew::API.fetch
  Homebrew::API.fetch "versions-casks.json"
end

.formulaeObject

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.



13
14
15
16
# File 'api/versions.rb', line 13

def formulae
  # The result is cached by Homebrew::API.fetch
  Homebrew::API.fetch "versions-formulae.json"
end

.latest_cask_version(token) ⇒ Version?

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:



34
35
36
37
38
39
40
41
42
43
# File 'api/versions.rb', line 34

def latest_cask_version(token)
  return unless casks.key? token

  version = if casks[token]["versions"].key? MacOS.version.to_sym.to_s
    casks[token]["versions"][MacOS.version.to_sym.to_s]
  else
    casks[token]["version"]
  end
  Version.new(version)
end

.latest_formula_version(name) ⇒ PkgVersion?

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:



24
25
26
27
28
29
30
31
# File 'api/versions.rb', line 24

def latest_formula_version(name)
  versions = formulae
  return unless versions.key? name

  version = Version.new(versions[name]["version"])
  revision = versions[name]["revision"]
  PkgVersion.new(version, revision)
end