@@ -216,9 +216,9 @@ def self.load_formula_from_path(name, path, flags:, ignore_errors:)
216216 platform_cache . fetch ( :path ) [ path . to_s ] = klass
217217 end
218218
219- sig { params ( name : String , json_formula_with_variations : T :: Hash [ String , T . untyped ] , flags : T ::Array [ String ] ) . returns ( T . class_of ( Formula ) ) }
220- def self . load_formula_from_json !( name , json_formula_with_variations , flags :)
221- namespace = :"FormulaNamespaceAPI#{ namespace_key ( json_formula_with_variations . to_json ) } "
219+ sig { params ( name : String , formula_struct : Homebrew :: API :: FormulaHash , flags : T ::Array [ String ] ) . returns ( T . class_of ( Formula ) ) }
220+ def self . load_formula_from_formula_struct !( name , formula_struct , flags :)
221+ namespace = :"FormulaNamespaceAPI#{ namespace_key ( formula_struct . to_json ) } "
222222
223223 mod = Module . new
224224 remove_const ( namespace ) if const_defined? ( namespace )
@@ -227,9 +227,8 @@ def self.load_formula_from_json!(name, json_formula_with_variations, flags:)
227227 mod . const_set ( :BUILD_FLAGS , flags )
228228
229229 class_name = class_s ( name )
230- json_formula = Homebrew ::API . merge_variations ( json_formula_with_variations )
231230
232- caveats_string = ( replace_placeholders ( json_formula [ " caveats" ] ) if json_formula [ " caveats" ] )
231+ caveats_string = ( replace_placeholders ( formula_struct . caveats ) if formula_struct . caveats )
233232
234233 uses_from_macos_names = json_formula . fetch ( "uses_from_macos" , [ ] ) . map do |dep |
235234 next dep unless dep . is_a? Hash
@@ -1079,7 +1078,8 @@ def load_from_api(flags:)
10791078
10801079 raise FormulaUnavailableError , name if json_formula . nil?
10811080
1082- Formulary . load_formula_from_json! ( name , json_formula , flags :)
1081+ formula_struct = Homebrew ::API ::FormulaHash . from_hash ( json_formula )
1082+ Formulary . load_formula_from_formula_struct! ( name , formula_struct , flags :)
10831083 end
10841084 end
10851085
@@ -1095,7 +1095,8 @@ def initialize(name, contents, tap: nil, alias_name: nil)
10951095
10961096 sig { override . params ( flags : T ::Array [ String ] ) . void }
10971097 def load_from_api ( flags :)
1098- Formulary . load_formula_from_json! ( name , @contents , flags :)
1098+ formula_struct = Homebrew ::API ::FormulaHash . from_hash ( @contents )
1099+ Formulary . load_formula_from_formula_struct! ( name , formula_struct , flags :)
10991100 end
11001101 end
11011102
0 commit comments