Access table internally

This commit is contained in:
Douglas Eichelberger 2024-12-06 20:15:48 -08:00
parent 659f993dab
commit aa7da18d88

View File

@ -23,13 +23,7 @@ module Homebrew
@options_only = T.let([], T::Array[String]) @options_only = T.let([], T::Array[String])
@flags_only = T.let([], T::Array[String]) @flags_only = T.let([], T::Array[String])
@cask_options = T.let(false, T::Boolean) @cask_options = T.let(false, T::Boolean)
@table = T.let({ @table = T.let({}, T::Hash[Symbol, T.untyped])
build_bottle?: false,
build_from_source?: false,
force_bottle?: false,
HEAD?: false,
include_test?: false,
}, T::Hash[Symbol, T.untyped])
# Can set these because they will be overwritten by freeze_named_args! # Can set these because they will be overwritten by freeze_named_args!
# (whereas other values below will only be overwritten if passed). # (whereas other values below will only be overwritten if passed).
@ -47,8 +41,8 @@ module Homebrew
*named_args.freeze, *named_args.freeze,
cask_options:, cask_options:,
flags: flags_only, flags: flags_only,
force_bottle: force_bottle?, force_bottle: @table[:force_bottle?] || false,
override_spec: self.HEAD? ? :head : nil, override_spec: @table[:HEAD?] ? :head : nil,
parent: self, parent: self,
without_api:, without_api:,
), ),
@ -56,27 +50,6 @@ module Homebrew
) )
end end
sig { returns(T.nilable(String)) }
def arch = @table[:arch]
sig { returns(T::Boolean) }
def build_bottle? = @table.fetch(:build_bottle?)
sig { returns(T::Boolean) }
def build_from_source? = @table.fetch(:build_from_source?)
sig { returns(T::Boolean) }
def force_bottle? = @table.fetch(:force_bottle?)
sig { returns(T::Boolean) }
def HEAD? = @table.fetch(:HEAD?)
sig { returns(T::Boolean) }
def include_test? = @table.fetch(:include_test?)
sig { returns(T.nilable(String)) }
def os = @table[:os]
sig { params(name: Symbol, value: T.untyped).void } sig { params(name: Symbol, value: T.untyped).void }
def set_arg(name, value) def set_arg(name, value)
@table[name] = value @table[name] = value
@ -112,7 +85,7 @@ module Homebrew
sig { returns(T::Array[String]) } sig { returns(T::Array[String]) }
def build_from_source_formulae def build_from_source_formulae
if build_from_source? || self.HEAD? || build_bottle? if @table[:build_from_source?] || @table[:HEAD?] || @table[:build_bottle?]
named.to_formulae.map(&:full_name) named.to_formulae.map(&:full_name)
else else
[] []
@ -121,7 +94,7 @@ module Homebrew
sig { returns(T::Array[String]) } sig { returns(T::Array[String]) }
def include_test_formulae def include_test_formulae
if include_test? if @table[:include_test?]
named.to_formulae.map(&:full_name) named.to_formulae.map(&:full_name)
else else
[] []
@ -155,7 +128,7 @@ module Homebrew
def os_arch_combinations def os_arch_combinations
skip_invalid_combinations = false skip_invalid_combinations = false
oses = case (os_sym = os&.to_sym) oses = case (os_sym = @table[:os]&.to_sym)
when nil when nil
[SimulateSystem.current_os] [SimulateSystem.current_os]
when :all when :all
@ -166,7 +139,7 @@ module Homebrew
[os_sym] [os_sym]
end end
arches = case (arch_sym = arch&.to_sym) arches = case (arch_sym = @table[:arch]&.to_sym)
when nil when nil
[SimulateSystem.current_arch] [SimulateSystem.current_arch]
when :all when :all