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.



23
24
25
26
# File 'api/versions.rb', line 23

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:



46
47
48
49
50
51
52
53
54
55
# File 'api/versions.rb', line 46

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:



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

def latest_formula_version(name)
  versions = if OS.mac? ||
                Homebrew::EnvConfig.force_homebrew_on_linux? ||
                Homebrew::EnvConfig.force_homebrew_core_repo_on_linux?
    formulae
  else
    linux
  end

  return unless versions.key? name

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

.linuxObject

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 linux
  # The result is cached by Homebrew::API.fetch
  Homebrew::API.fetch "versions-linux.json"
end