This commit is contained in:
Rylan Polster 2022-06-16 13:26:51 -04:00
parent 0113774e90
commit dd81ca57ca
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64

View File

@ -155,16 +155,14 @@ module Formulary
root_url bottles_stable["root_url"] root_url bottles_stable["root_url"]
rebuild bottles_stable["rebuild"] rebuild bottles_stable["rebuild"]
bottles_stable["files"].each do |tag, bottle_spec| bottles_stable["files"].each do |tag, bottle_spec|
cellar = bottle_spec["cellar"] cellar = Formulary.convert_to_string_or_symbol bottle_spec["cellar"]
cellar = cellar[1..].to_sym if cellar.start_with?(":")
sha256 cellar: cellar, tag.to_sym => bottle_spec["sha256"] sha256 cellar: cellar, tag.to_sym => bottle_spec["sha256"]
end end
end end
end end
if (keg_only_reason = json_formula["keg_only_reason"]).present? if (keg_only_reason = json_formula["keg_only_reason"]).present?
reason = keg_only_reason["reason"] reason = Formulary.convert_to_string_or_symbol keg_only_reason["reason"]
reason = reason[1..].to_sym if reason.start_with?(":")
keg_only reason, keg_only_reason["explanation"] keg_only reason, keg_only_reason["explanation"]
end end
@ -257,6 +255,12 @@ module Formulary
class_name class_name
end end
def self.convert_to_string_or_symbol(string)
return string[1..].to_sym if string.start_with?(":")
string
end
# A {FormulaLoader} returns instances of formulae. # A {FormulaLoader} returns instances of formulae.
# Subclasses implement loaders for particular sources of formulae. # Subclasses implement loaders for particular sources of formulae.
class FormulaLoader class FormulaLoader
@ -501,7 +505,6 @@ module Formulary
def load_from_api(flags:) def load_from_api(flags:)
$stderr.puts "#{$PROGRAM_NAME} (#{self.class.name}): loading #{name} from API" if debug? $stderr.puts "#{$PROGRAM_NAME} (#{self.class.name}): loading #{name} from API" if debug?
# raise FormulaUnavailableError, name unless path.file?
Formulary.load_formula_from_api(name, flags: flags) Formulary.load_formula_from_api(name, flags: flags)
end end