Module: Homebrew::API::Internal Private

Extended by:
Cachable
Defined in:
api/internal.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 JSON internal API.

Class Method Summary collapse

Methods included from Cachable

cache, clear_cache

Class Method Details

.cached_packages_json_file_pathPathname

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.

Returns:



53
54
55
# File 'api/internal.rb', line 53

def self.cached_packages_json_file_path
  HOMEBREW_CACHE_API/packages_endpoint
end

.cask_hashesHash{String => Hash{String => 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.

Returns:



153
154
155
156
157
158
159
160
# File 'api/internal.rb', line 153

def self.cask_hashes
  unless cache.key?("cask_hashes")
    updated = download_and_cache_data!
    write_cask_names(regenerate: updated)
  end

  cache["cask_hashes"]
end

.cask_renamesHash{String => String}

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.

Returns:



163
164
165
166
167
168
169
170
# File 'api/internal.rb', line 163

def self.cask_renames
  unless cache.key?("cask_renames")
    updated = download_and_cache_data!
    write_cask_names(regenerate: updated)
  end

  cache["cask_renames"]
end

.cask_struct(name) ⇒ Homebrew::API::CaskStruct

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:



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'api/internal.rb', line 38

def self.cask_struct(name)
  return cache["cask_structs"][name] if cache.key?("cask_structs") && cache["cask_structs"].key?(name)

  hash = cask_hashes[name]
  raise "No cask found for #{name}" unless hash

  struct = Homebrew::API::CaskStruct.deserialize(hash)

  cache["cask_structs"] ||= {}
  cache["cask_structs"][name] = struct

  struct
end

.cask_tap_git_headString

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.

Returns:



183
184
185
186
187
188
189
190
# File 'api/internal.rb', line 183

def self.cask_tap_git_head
  unless cache.key?("cask_tap_git_head")
    updated = download_and_cache_data!
    write_cask_names(regenerate: updated)
  end

  cache["cask_tap_git_head"]
end

.cask_tap_migrationsHash{String => String}

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.

Returns:



173
174
175
176
177
178
179
180
# File 'api/internal.rb', line 173

def self.cask_tap_migrations
  unless cache.key?("cask_tap_migrations")
    updated = download_and_cache_data!
    write_cask_names(regenerate: updated)
  end

  cache["cask_tap_migrations"]
end

.fetch_packages_api!(download_queue: Homebrew.default_download_queue, stale_seconds: nil, enqueue: false) ⇒ Array<(Hash{String => T.untyped}, 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:

  • download_queue (Homebrew::DownloadQueue) (defaults to: Homebrew.default_download_queue)
  • stale_seconds (Integer, nil) (defaults to: nil)
  • enqueue (Boolean) (defaults to: false)

Returns:



61
62
63
64
65
66
# File 'api/internal.rb', line 61

def self.fetch_packages_api!(download_queue: Homebrew.default_download_queue, stale_seconds: nil,
                             enqueue: false)
  json_contents, updated = Homebrew::API.fetch_json_api_file(packages_endpoint, stale_seconds:, download_queue:,
                                                             enqueue:)
  [T.cast(json_contents, T::Hash[String, T.untyped]), updated]
end

.formula_aliasesHash{String => String}

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.

Returns:



113
114
115
116
117
118
119
120
# File 'api/internal.rb', line 113

def self.formula_aliases
  unless cache.key?("formula_aliases")
    updated = download_and_cache_data!
    write_formula_names_and_aliases(regenerate: updated)
  end

  cache["formula_aliases"]
end

.formula_hashesHash{String => Hash{String => 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.

Returns:



103
104
105
106
107
108
109
110
# File 'api/internal.rb', line 103

def self.formula_hashes
  unless cache.key?("formula_hashes")
    updated = download_and_cache_data!
    write_formula_names_and_aliases(regenerate: updated)
  end

  cache["formula_hashes"]
end

.formula_renamesHash{String => String}

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.

Returns:



123
124
125
126
127
128
129
130
# File 'api/internal.rb', line 123

def self.formula_renames
  unless cache.key?("formula_renames")
    updated = download_and_cache_data!
    write_formula_names_and_aliases(regenerate: updated)
  end

  cache["formula_renames"]
end

.formula_struct(name) ⇒ Homebrew::API::FormulaStruct

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:



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'api/internal.rb', line 23

def self.formula_struct(name)
  return cache["formula_structs"][name] if cache.key?("formula_structs") && cache["formula_structs"].key?(name)

  hash = formula_hashes[name]
  raise "No formula found for #{name}" unless hash

  struct = Homebrew::API::FormulaStruct.deserialize(hash, bottle_tag: SimulateSystem.current_tag)

  cache["formula_structs"] ||= {}
  cache["formula_structs"][name] = struct

  struct
end

.formula_tap_git_headString

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.

Returns:



143
144
145
146
147
148
149
150
# File 'api/internal.rb', line 143

def self.formula_tap_git_head
  unless cache.key?("formula_tap_git_head")
    updated = download_and_cache_data!
    write_formula_names_and_aliases(regenerate: updated)
  end

  cache["formula_tap_git_head"]
end

.formula_tap_migrationsHash{String => String}

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.

Returns:



133
134
135
136
137
138
139
140
# File 'api/internal.rb', line 133

def self.formula_tap_migrations
  unless cache.key?("formula_tap_migrations")
    updated = download_and_cache_data!
    write_formula_names_and_aliases(regenerate: updated)
  end

  cache["formula_tap_migrations"]
end

.packages_endpointString

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.

Returns:



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

def self.packages_endpoint
  "internal/packages.#{SimulateSystem.current_tag}.jws.json"
end

.write_cask_names(regenerate: false) ⇒ 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.

Parameters:

  • regenerate (Boolean) (defaults to: false)


96
97
98
99
100
# File 'api/internal.rb', line 96

def self.write_cask_names(regenerate: false)
  download_and_cache_data! unless cache.key?("cask_hashes")

  Homebrew::API.write_names_file!(cask_hashes.keys, "cask", regenerate:)
end

.write_formula_names_and_aliases(regenerate: false) ⇒ 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.

Parameters:

  • regenerate (Boolean) (defaults to: false)


88
89
90
91
92
93
# File 'api/internal.rb', line 88

def self.write_formula_names_and_aliases(regenerate: false)
  download_and_cache_data! unless cache.key?("formula_hashes")

  Homebrew::API.write_names_file!(formula_hashes.keys, "formula", regenerate:)
  Homebrew::API.write_aliases_file!(formula_aliases, "formula", regenerate:)
end