Module: Homebrew::API::Internal Private
- Extended by:
- Cachable, T::Generic
- 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.
Constant Summary collapse
- Cache =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
type_template { { fixed: T::Hash[String, T.untyped] } }
Class Method Summary collapse
- .cached_packages_json_file_path ⇒ Pathname private
- .cask_hashes ⇒ Hash{String => Hash{String => T.untyped}} private
- .cask_renames ⇒ Hash{String => String} private
- .cask_struct(name) ⇒ Homebrew::API::CaskStruct private
- .cask_tap_git_head ⇒ String private
- .cask_tap_migrations ⇒ Hash{String => String} private
- .fetch_packages_api!(download_queue: nil, stale_seconds: nil, enqueue: false) ⇒ Array<(Hash{String => T.untyped}, Boolean)> private
- .formula_aliases ⇒ Hash{String => String} private
- .formula_hashes ⇒ Hash{String => Hash{String => T.untyped}} private
-
.formula_hashes_cached? ⇒ Boolean
private
Whether formula hashes are already loaded, so callers can use them opportunistically without triggering a download and full JSON parse.
- .formula_renames ⇒ Hash{String => String} private
- .formula_struct(name) ⇒ Homebrew::API::FormulaStruct private
- .formula_tap_git_head ⇒ String private
- .formula_tap_migrations ⇒ Hash{String => String} private
- .write_cask_names(regenerate: false) ⇒ void private
- .write_formula_names_and_aliases(regenerate: false) ⇒ void private
Methods included from Cachable
Class Method Details
.cached_packages_json_file_path ⇒ Pathname
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.
64 65 66 |
# File 'api/internal.rb', line 64 def self.cached_packages_json_file_path HOMEBREW_CACHE_API/packages_endpoint end |
.cask_hashes ⇒ Hash{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.
180 181 182 183 184 185 186 187 |
# File 'api/internal.rb', line 180 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_renames ⇒ Hash{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.
190 191 192 193 194 195 196 197 |
# File 'api/internal.rb', line 190 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.
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'api/internal.rb', line 49 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_head ⇒ 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.
210 211 212 213 214 215 216 217 |
# File 'api/internal.rb', line 210 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_migrations ⇒ Hash{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.
200 201 202 203 204 205 206 207 |
# File 'api/internal.rb', line 200 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: nil, 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.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'api/internal.rb', line 72 def self.fetch_packages_api!(download_queue: nil, stale_seconds: nil, enqueue: false) old_failed = Homebrew.failed? json_contents, updated = begin Homebrew::API.fetch_json_api_file(packages_endpoint, stale_seconds:, download_queue:, enqueue:) rescue ErrorDuringExecution => e raise if e.stderr.exclude?("HTTP status: 404") || effective_tag == fallback_tag @effective_tag = fallback_tag Homebrew.failed = old_failed retry end [T.cast(json_contents, T::Hash[String, T.untyped]), updated] end |
.formula_aliases ⇒ Hash{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.
140 141 142 143 144 145 146 147 |
# File 'api/internal.rb', line 140 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_hashes ⇒ Hash{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.
130 131 132 133 134 135 136 137 |
# File 'api/internal.rb', line 130 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_hashes_cached? ⇒ 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.
Whether formula hashes are already loaded, so callers can use them opportunistically without triggering a download and full JSON parse.
125 126 127 |
# File 'api/internal.rb', line 125 def self.formula_hashes_cached? cache.key?("formula_hashes") end |
.formula_renames ⇒ Hash{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.
150 151 152 153 154 155 156 157 |
# File 'api/internal.rb', line 150 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.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'api/internal.rb', line 34 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: effective_tag) cache["formula_structs"] ||= {} cache["formula_structs"][name] = struct struct end |
.formula_tap_git_head ⇒ 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.
170 171 172 173 174 175 176 177 |
# File 'api/internal.rb', line 170 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_migrations ⇒ Hash{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.
160 161 162 163 164 165 166 167 |
# File 'api/internal.rb', line 160 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 |
.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.
116 117 118 119 120 |
# File 'api/internal.rb', line 116 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.
107 108 109 110 111 112 113 |
# File 'api/internal.rb', line 107 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:) Homebrew::API.write_executables_file!(formula_hashes, regenerate:, source: cached_packages_json_file_path) end |