Class: Homebrew::API::FormulaStruct Private
- Defined in:
- api/formula_struct.rb,
sorbet/rbi/dsl/homebrew/api/formula_struct.rbi
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Constant Summary collapse
- PREDICATES =
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.
[ :bottle, :deprecate, :disable, :head, :keg_only, :no_autobump, :pour_bottle, :service, :service_run, :service_name, :stable, ].freeze
- SKIP_SERIALIZATION =
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.
[ # Bottle checksums have special serialization done by the serialize_bottle method :bottle_checksums, ].freeze
- SPECS =
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.
[:head, :stable].freeze
- DEFAULT_CELLAR =
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.
:any_skip_relocation is the most common in homebrew/core
:any_skip_relocation- DependsOnArgs =
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.
T.type_alias do T.any( # Dependencies T.any( # Formula name: "foo" String, # Formula name and dependency type: { "foo" => :build } T::Hash[String, Symbol], ), # Requirements T.any( # Requirement name: :macos Symbol, # Requirement name and other info: { macos: :build } T::Hash[Symbol, T::Array[T.anything]], ), ) end
- UsesFromMacOSArgs =
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.
T.type_alias do [ T.any( # Formula name: "foo" String, # Formula name and dependency type: { "foo" => :build } # Formula name, dependency type, and version bounds: { "foo" => :build, since: :catalina } T::Hash[T.any(String, Symbol), T.any(Symbol, T::Array[Symbol])], ), # If the first argument is only a name, this argument contains the version bounds: { since: :catalina } T::Hash[Symbol, Symbol], ] end
Instance Attribute Summary collapse
-
#aliases ⇒ Array<String>
readonly
private
Changes to this struct must be mirrored in Homebrew::API::Formula.generate_formula_struct_hash.
-
#bottle_checksums ⇒ Array<Hash{Symbol => String, Symbol}>
readonly
private
Returns the value of prop
bottle_checksums. -
#bottle_rebuild ⇒ Integer
readonly
private
Returns the value of prop
bottle_rebuild. -
#caveats ⇒ String?
readonly
private
Returns the value of prop
caveats. -
#conflicts ⇒ Array<Array<(String, Hash{Symbol => String})>>
readonly
private
Returns the value of prop
conflicts. -
#deprecate_args ⇒ Hash{Symbol => String, Symbol, nil}
readonly
private
Returns the value of prop
deprecate_args. -
#desc ⇒ String
readonly
private
Returns the value of prop
desc. -
#disable_args ⇒ Hash{Symbol => String, Symbol, nil}
readonly
private
Returns the value of prop
disable_args. -
#head_dependencies ⇒ Array<DependsOnArgs>
readonly
private
Returns the value of prop
head_dependencies. -
#head_url_args ⇒ Array<(String, Hash{Symbol => T.anything})>
readonly
private
Returns the value of prop
head_url_args. -
#head_uses_from_macos ⇒ Array<UsesFromMacOSArgs>
readonly
private
Returns the value of prop
head_uses_from_macos. -
#homepage ⇒ String
readonly
private
Returns the value of prop
homepage. -
#keg_only_args ⇒ Array<String, Symbol>
readonly
private
Returns the value of prop
keg_only_args. -
#license ⇒ SPDX::LicenseExpression
readonly
private
Returns the value of prop
license. -
#link_overwrite_paths ⇒ Array<String>
readonly
private
Returns the value of prop
link_overwrite_paths. -
#no_autobump_args ⇒ Hash{Symbol => String, Symbol}
readonly
private
Returns the value of prop
no_autobump_args. -
#oldnames ⇒ Array<String>
readonly
private
Returns the value of prop
oldnames. -
#post_install_defined ⇒ Boolean
readonly
private
Returns the value of prop
post_install_defined. -
#pour_bottle_args ⇒ Hash{Symbol => Symbol}
readonly
private
Returns the value of prop
pour_bottle_args. -
#revision ⇒ Integer
readonly
private
Returns the value of prop
revision. -
#ruby_source_checksum ⇒ String
readonly
private
Returns the value of prop
ruby_source_checksum. -
#service_args ⇒ Array<Array<(Symbol, BasicObject)>>
readonly
private
Returns the value of prop
service_args. -
#service_name_args ⇒ Hash{Symbol => String}
readonly
private
Returns the value of prop
service_name_args. -
#service_run_args ⇒ Array<Homebrew::Service::RunParam>
readonly
private
Returns the value of prop
service_run_args. -
#service_run_kwargs ⇒ Hash{Symbol => Homebrew::Service::RunParam}
readonly
private
Returns the value of prop
service_run_kwargs. -
#stable_checksum ⇒ String?
readonly
private
Returns the value of prop
stable_checksum. -
#stable_dependencies ⇒ Array<DependsOnArgs>
readonly
private
Returns the value of prop
stable_dependencies. -
#stable_url_args ⇒ Array<(String, Hash{Symbol => T.anything})>
readonly
private
Returns the value of prop
stable_url_args. -
#stable_uses_from_macos ⇒ Array<UsesFromMacOSArgs>
readonly
private
Returns the value of prop
stable_uses_from_macos. -
#stable_version ⇒ String
readonly
private
Returns the value of prop
stable_version. -
#version_scheme ⇒ Integer
readonly
private
Returns the value of prop
version_scheme. -
#versioned_formulae ⇒ Array<String>
readonly
private
Returns the value of prop
versioned_formulae.
Class Method Summary collapse
- .deep_compact_blank(obj) ⇒ T.type_parameter(:U)? private
- .deep_stringify_symbols(obj) ⇒ T.untyped private
- .deep_unstringify_symbols(obj) ⇒ T.untyped private
- .deserialize(hash, bottle_tag: ::Utils::Bottles.tag) ⇒ FormulaStruct private
-
.format_arg_pair(args, last:) ⇒ Array<(T.type_parameter(:U), T.type_parameter(:V))>
private
Format argument pairs into proper [first, last] format if serialization has removed some elements.
- .from_hash(formula_hash) ⇒ FormulaStruct private
-
.stringify_symbol(value) ⇒ String?
private
Converts a symbol to a string starting with
:, otherwise returns the input.
Instance Method Summary collapse
- #bottle? ⇒ Boolean private
- #deprecate? ⇒ Boolean private
- #disable? ⇒ Boolean private
- #head? ⇒ Boolean private
- #initialize(aliases: [], bottle_checksums: [], bottle_rebuild: 0, caveats: nil, conflicts: [], deprecate_args: {}, desc:, disable_args: {}, head_dependencies: [], head_url_args: ["", {}], head_uses_from_macos: [], homepage:, keg_only_args: [], license:, link_overwrite_paths: [], no_autobump_args: {}, oldnames: [], post_install_defined: true, pour_bottle_args: {}, revision: 0, ruby_source_checksum:, service_args: [], service_name_args: {}, service_run_args: [], service_run_kwargs: {}, stable_dependencies: [], stable_checksum: nil, stable_url_args: ["", {}], stable_uses_from_macos: [], stable_version:, version_scheme: 0, versioned_formulae: []) ⇒ void constructor
- #keg_only? ⇒ Boolean private
- #no_autobump? ⇒ Boolean private
- #pour_bottle? ⇒ Boolean private
- #serialize(bottle_tag: ::Utils::Bottles.tag) ⇒ Hash{String => T.untyped} private
- #serialize_bottle(bottle_tag: ::Utils::Bottles.tag) ⇒ Hash{String => T.untyped}? private
- #service? ⇒ Boolean private
- #service_name? ⇒ Boolean private
- #service_run? ⇒ Boolean private
- #stable? ⇒ Boolean private
Constructor Details
#initialize(aliases: [], bottle_checksums: [], bottle_rebuild: 0, caveats: nil, conflicts: [], deprecate_args: {}, desc:, disable_args: {}, head_dependencies: [], head_url_args: ["", {}], head_uses_from_macos: [], homepage:, keg_only_args: [], license:, link_overwrite_paths: [], no_autobump_args: {}, oldnames: [], post_install_defined: true, pour_bottle_args: {}, revision: 0, ruby_source_checksum:, service_args: [], service_name_args: {}, service_run_args: [], service_run_kwargs: {}, stable_dependencies: [], stable_checksum: nil, stable_url_args: ["", {}], stable_uses_from_macos: [], stable_version:, version_scheme: 0, versioned_formulae: []) ⇒ void
|
|
# File '' const :aliases, T::Array[String], default: [] const :bottle_checksums, T::Array[T::Hash[Symbol, T.any(String, Symbol)]], default: [] const :bottle_rebuild, Integer, default: 0 const :caveats, T.nilable(String) const :conflicts, T::Array[[String, T::Hash[Symbol, String]]], default: [] const :deprecate_args, T::Hash[Symbol, T.nilable(T.any(String, Symbol))], default: {} const :desc, String const :disable_args, T::Hash[Symbol, T.nilable(T.any(String, Symbol))], default: {} const :head_dependencies, T::Array[DependsOnArgs], default: [] const :head_url_args, [String, T::Hash[Symbol, T.anything]], default: ["", {}] const :head_uses_from_macos, T::Array[UsesFromMacOSArgs], default: [] const :homepage, String const :keg_only_args, T::Array[T.any(String, Symbol)], default: [] const :license, SPDX::LicenseExpression const :link_overwrite_paths, T::Array[String], default: [] const :no_autobump_args, T::Hash[Symbol, T.any(String, Symbol)], default: {} const :oldnames, T::Array[String], default: [] const :post_install_defined, T::Boolean, default: true const :pour_bottle_args, T::Hash[Symbol, Symbol], default: {} const :revision, Integer, default: 0 const :ruby_source_checksum, String const :service_args, T::Array[[Symbol, BasicObject]], default: [] const :service_name_args, T::Hash[Symbol, String], default: {} const :service_run_args, T::Array[Homebrew::Service::RunParam], default: [] const :service_run_kwargs, T::Hash[Symbol, Homebrew::Service::RunParam], default: {} const :stable_dependencies, T::Array[DependsOnArgs], default: [] const :stable_checksum, T.nilable(String) const :stable_url_args, [String, T::Hash[Symbol, T.anything]], default: ["", {}] const :stable_uses_from_macos, T::Array[UsesFromMacOSArgs], default: [] const :stable_version, String const :version_scheme, Integer, default: 0 const :versioned_formulae, T::Array[String], default: [] |
Instance Attribute Details
#aliases ⇒ Array<String> (readonly)
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.
Changes to this struct must be mirrored in Homebrew::API::Formula.generate_formula_struct_hash
|
|
# File '' const :aliases, T::Array[String], default: [] |
#bottle_checksums ⇒ Array<Hash{Symbol => String, Symbol}> (readonly)
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 the value of prop bottle_checksums.
|
|
# File '' const :bottle_checksums, T::Array[T::Hash[Symbol, T.any(String, Symbol)]], default: [] |
#bottle_rebuild ⇒ Integer (readonly)
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 the value of prop bottle_rebuild.
|
|
# File '' const :bottle_rebuild, Integer, default: 0 |
#caveats ⇒ String? (readonly)
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 the value of prop caveats.
|
|
# File '' const :caveats, T.nilable(String) |
#conflicts ⇒ Array<Array<(String, Hash{Symbol => String})>> (readonly)
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 the value of prop conflicts.
|
|
# File '' const :conflicts, T::Array[[String, T::Hash[Symbol, String]]], default: [] |
#deprecate_args ⇒ Hash{Symbol => String, Symbol, nil} (readonly)
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 the value of prop deprecate_args.
|
|
# File '' const :deprecate_args, T::Hash[Symbol, T.nilable(T.any(String, Symbol))], default: {} |
#desc ⇒ String (readonly)
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 the value of prop desc.
|
|
# File '' const :desc, String |
#disable_args ⇒ Hash{Symbol => String, Symbol, nil} (readonly)
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 the value of prop disable_args.
|
|
# File '' const :disable_args, T::Hash[Symbol, T.nilable(T.any(String, Symbol))], default: {} |
#head_dependencies ⇒ Array<DependsOnArgs> (readonly)
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 the value of prop head_dependencies.
|
|
# File '' const :head_dependencies, T::Array[DependsOnArgs], default: [] |
#head_url_args ⇒ Array<(String, Hash{Symbol => T.anything})> (readonly)
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 the value of prop head_url_args.
|
|
# File '' const :head_url_args, [String, T::Hash[Symbol, T.anything]], default: ["", {}] |
#head_uses_from_macos ⇒ Array<UsesFromMacOSArgs> (readonly)
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 the value of prop head_uses_from_macos.
|
|
# File '' const :head_uses_from_macos, T::Array[UsesFromMacOSArgs], default: [] |
#homepage ⇒ String (readonly)
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 the value of prop homepage.
|
|
# File '' const :homepage, String |
#keg_only_args ⇒ Array<String, Symbol> (readonly)
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 the value of prop keg_only_args.
|
|
# File '' const :keg_only_args, T::Array[T.any(String, Symbol)], default: [] |
#license ⇒ SPDX::LicenseExpression (readonly)
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 the value of prop license.
|
|
# File '' const :license, SPDX::LicenseExpression |
#link_overwrite_paths ⇒ Array<String> (readonly)
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 the value of prop link_overwrite_paths.
|
|
# File '' const :link_overwrite_paths, T::Array[String], default: [] |
#no_autobump_args ⇒ Hash{Symbol => String, Symbol} (readonly)
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 the value of prop no_autobump_args.
|
|
# File '' const :no_autobump_args, T::Hash[Symbol, T.any(String, Symbol)], default: {} |
#oldnames ⇒ Array<String> (readonly)
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 the value of prop oldnames.
|
|
# File '' const :oldnames, T::Array[String], default: [] |
#post_install_defined ⇒ Boolean (readonly)
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 the value of prop post_install_defined.
|
|
# File '' const :post_install_defined, T::Boolean, default: true |
#pour_bottle_args ⇒ Hash{Symbol => Symbol} (readonly)
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 the value of prop pour_bottle_args.
|
|
# File '' const :pour_bottle_args, T::Hash[Symbol, Symbol], default: {} |
#revision ⇒ Integer (readonly)
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 the value of prop revision.
|
|
# File '' const :revision, Integer, default: 0 |
#ruby_source_checksum ⇒ String (readonly)
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 the value of prop ruby_source_checksum.
|
|
# File '' const :ruby_source_checksum, String |
#service_args ⇒ Array<Array<(Symbol, BasicObject)>> (readonly)
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 the value of prop service_args.
|
|
# File '' const :service_args, T::Array[[Symbol, BasicObject]], default: [] |
#service_name_args ⇒ Hash{Symbol => String} (readonly)
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 the value of prop service_name_args.
|
|
# File '' const :service_name_args, T::Hash[Symbol, String], default: {} |
#service_run_args ⇒ Array<Homebrew::Service::RunParam> (readonly)
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 the value of prop service_run_args.
|
|
# File '' const :service_run_args, T::Array[Homebrew::Service::RunParam], default: [] |
#service_run_kwargs ⇒ Hash{Symbol => Homebrew::Service::RunParam} (readonly)
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 the value of prop service_run_kwargs.
|
|
# File '' const :service_run_kwargs, T::Hash[Symbol, Homebrew::Service::RunParam], default: {} |
#stable_checksum ⇒ String? (readonly)
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 the value of prop stable_checksum.
|
|
# File '' const :stable_checksum, T.nilable(String) |
#stable_dependencies ⇒ Array<DependsOnArgs> (readonly)
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 the value of prop stable_dependencies.
|
|
# File '' const :stable_dependencies, T::Array[DependsOnArgs], default: [] |
#stable_url_args ⇒ Array<(String, Hash{Symbol => T.anything})> (readonly)
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 the value of prop stable_url_args.
|
|
# File '' const :stable_url_args, [String, T::Hash[Symbol, T.anything]], default: ["", {}] |
#stable_uses_from_macos ⇒ Array<UsesFromMacOSArgs> (readonly)
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 the value of prop stable_uses_from_macos.
|
|
# File '' const :stable_uses_from_macos, T::Array[UsesFromMacOSArgs], default: [] |
#stable_version ⇒ String (readonly)
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 the value of prop stable_version.
|
|
# File '' const :stable_version, String |
#version_scheme ⇒ Integer (readonly)
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 the value of prop version_scheme.
|
|
# File '' const :version_scheme, Integer, default: 0 |
#versioned_formulae ⇒ Array<String> (readonly)
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 the value of prop versioned_formulae.
|
|
# File '' const :versioned_formulae, T::Array[String], default: [] |
Class Method Details
.deep_compact_blank(obj) ⇒ T.type_parameter(:U)?
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.
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'api/formula_struct.rb', line 304 def self.deep_compact_blank(obj) obj = case obj when Hash obj.transform_values { |v| deep_compact_blank(v) } .compact when Array obj.filter_map { |v| deep_compact_blank(v) } else obj end return if obj.blank? || (obj.is_a?(Numeric) && obj.zero?) obj end |
.deep_stringify_symbols(obj) ⇒ 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.
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'api/formula_struct.rb', line 257 def self.deep_stringify_symbols(obj) case obj when String # Escape leading : or \ to avoid confusion with stringified symbols # ":foo" -> "\:foo" # "\foo" -> "\\foo" if obj.start_with?(":", "\\") "\\#{obj}" else obj end when Symbol ":#{obj}" when Hash obj.to_h { |k, v| [deep_stringify_symbols(k), deep_stringify_symbols(v)] } when Array obj.map { |v| deep_stringify_symbols(v) } else obj end end |
.deep_unstringify_symbols(obj) ⇒ 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.
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'api/formula_struct.rb', line 280 def self.deep_unstringify_symbols(obj) case obj when String if obj.start_with?("\\") obj[1..] elsif obj.start_with?(":") T.must(obj[1..]).to_sym else obj end when Hash obj.to_h { |k, v| [deep_unstringify_symbols(k), deep_unstringify_symbols(v)] } when Array obj.map { |v| deep_unstringify_symbols(v) } else obj end end |
.deserialize(hash, bottle_tag: ::Utils::Bottles.tag) ⇒ 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.
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'api/formula_struct.rb', line 175 def self.deserialize(hash, bottle_tag: ::Utils::Bottles.tag) hash = deep_unstringify_symbols(hash) # Items that don't follow the `hash["foo_present"] = hash["foo_args"].present?` pattern are overridden below PREDICATES.each do |name| hash["#{name}_present"] = hash["#{name}_args"].present? end if (bottle_checksum = hash["bottle_checksum"]) tag = hash.fetch("bottle_tag", bottle_tag.to_sym) cellar = hash.fetch("bottle_cellar", DEFAULT_CELLAR) hash["bottle_present"] = true hash["bottle_checksums"] = [{ cellar: cellar, tag => bottle_checksum }] else hash["bottle_present"] = false end # *_url_args need to be in [String, Hash] format, but the hash may have been dropped if empty SPECS.each do |key| if (url_args = hash["#{key}_url_args"]) hash["#{key}_present"] = true hash["#{key}_url_args"] = format_arg_pair(url_args, last: {}) else hash["#{key}_present"] = false end next unless (uses_from_macos = hash["#{key}_uses_from_macos"]) hash["#{key}_uses_from_macos"] = uses_from_macos.map do |args| format_arg_pair(args, last: {}) end end hash["service_args"] = if (service_args = hash["service_args"]) service_args.map { |service_arg| format_arg_pair(service_arg, last: nil) } end hash["conflicts"] = if (conflicts = hash["conflicts"]) conflicts.map { |conflict| format_arg_pair(conflict, last: {}) } end from_hash(hash) end |
.format_arg_pair(args, last:) ⇒ Array<(T.type_parameter(:U), T.type_parameter(:V))>
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.
Format argument pairs into proper [first, last] format if serialization has removed some elements. Pass a default value for last to be used when only one element is present.
format_arg_pair(["foo"], last: {}) # => ["foo", {}] format_arg_pair([{ "foo" => :build }], last: {}) # => [{ "foo" => :build }, {}] format_arg_pair(["foo", { since: :catalina }], last: {}) # => ["foo", { since: :catalina }]
233 234 235 236 237 238 239 240 241 242 243 |
# File 'api/formula_struct.rb', line 233 def self.format_arg_pair(args, last:) args = case args in [elem] [elem, last] in [elem1, elem2] [elem1, elem2] end # The case above is exhaustive so args will never be nil, but sorbet cannot infer that. T.must(args) end |
.from_hash(formula_hash) ⇒ 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.
11 12 13 14 15 16 |
# File 'api/formula_struct.rb', line 11 def self.from_hash(formula_hash) formula_hash = formula_hash.transform_keys(&:to_sym) .slice(*decorator.all_props) .compact_blank new(**formula_hash) end |
.stringify_symbol(value) ⇒ 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.
Converts a symbol to a string starting with :, otherwise returns the input.
stringify_symbol(:example) # => ":example" stringify_symbol("example") # => "example"
250 251 252 253 254 |
# File 'api/formula_struct.rb', line 250 def self.stringify_symbol(value) return ":#{value}" if value.is_a?(Symbol) value end |
Instance Method Details
#bottle? ⇒ 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.
10 |
# File 'sorbet/rbi/dsl/homebrew/api/formula_struct.rbi', line 10 def bottle?; end |
#deprecate? ⇒ 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.
13 |
# File 'sorbet/rbi/dsl/homebrew/api/formula_struct.rbi', line 13 def deprecate?; end |
#disable? ⇒ 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.
16 |
# File 'sorbet/rbi/dsl/homebrew/api/formula_struct.rbi', line 16 def disable?; end |
#head? ⇒ 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.
19 |
# File 'sorbet/rbi/dsl/homebrew/api/formula_struct.rbi', line 19 def head?; end |
#keg_only? ⇒ 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.
22 |
# File 'sorbet/rbi/dsl/homebrew/api/formula_struct.rbi', line 22 def keg_only?; end |
#no_autobump? ⇒ 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.
25 |
# File 'sorbet/rbi/dsl/homebrew/api/formula_struct.rbi', line 25 def no_autobump?; end |
#pour_bottle? ⇒ 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.
28 |
# File 'sorbet/rbi/dsl/homebrew/api/formula_struct.rbi', line 28 def pour_bottle?; end |
#serialize(bottle_tag: ::Utils::Bottles.tag) ⇒ 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.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'api/formula_struct.rb', line 158 def serialize(bottle_tag: ::Utils::Bottles.tag) hash = self.class.decorator.all_props.filter_map do |prop| next if PREDICATES.any? { |predicate| prop == :"#{predicate}_present" } next if SKIP_SERIALIZATION.include?(prop) [prop.to_s, send(prop)] end.to_h if (bottle_hash = serialize_bottle(bottle_tag:)) hash = hash.merge(bottle_hash) end hash = self.class.deep_stringify_symbols(hash) self.class.deep_compact_blank(hash) end |
#serialize_bottle(bottle_tag: ::Utils::Bottles.tag) ⇒ 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.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'api/formula_struct.rb', line 131 def serialize_bottle(bottle_tag: ::Utils::Bottles.tag) bottle_collector = ::Utils::Bottles::Collector.new bottle_checksums.each do |bottle_info| bottle_info = bottle_info.dup cellar = bottle_info.delete(:cellar) || :any tag = T.must(bottle_info.keys.first) checksum = T.cast(bottle_info.values.first, String) bottle_collector.add( ::Utils::Bottles::Tag.from_symbol(tag), checksum: Checksum.new(checksum), cellar:, ) end return unless (bottle_spec = bottle_collector.specification_for(bottle_tag)) tag = (bottle_spec.tag if bottle_spec.tag != bottle_tag) cellar = (bottle_spec.cellar if bottle_spec.cellar != DEFAULT_CELLAR) { "bottle_tag" => tag&.to_sym, "bottle_cellar" => cellar, "bottle_checksum" => bottle_spec.checksum.to_s, } end |
#service? ⇒ 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.
31 |
# File 'sorbet/rbi/dsl/homebrew/api/formula_struct.rbi', line 31 def service?; end |
#service_name? ⇒ 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.
34 |
# File 'sorbet/rbi/dsl/homebrew/api/formula_struct.rbi', line 34 def service_name?; end |
#service_run? ⇒ 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.
37 |
# File 'sorbet/rbi/dsl/homebrew/api/formula_struct.rbi', line 37 def service_run?; end |
#stable? ⇒ 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.
40 |
# File 'sorbet/rbi/dsl/homebrew/api/formula_struct.rbi', line 40 def stable?; end |