Merge pull request #13437 from Rylan12/formulary-api-improvements
Formulary Improvements with `HOMEBREW_INSTALL_FROM_API`
This commit is contained in:
commit
42054ad7d5
@ -167,11 +167,13 @@ module Formulary
|
||||
end
|
||||
|
||||
if (deprecation_date = json_formula["deprecation_date"]).present?
|
||||
deprecate! date: deprecation_date, because: json_formula["deprecation_reason"]
|
||||
reason = Formulary.convert_to_deprecate_disable_reason_string_or_symbol json_formula["deprecation_reason"]
|
||||
deprecate! date: deprecation_date, because: reason
|
||||
end
|
||||
|
||||
if (disable_date = json_formula["disable_date"]).present?
|
||||
disable! date: disable_date, because: json_formula["disable_reason"]
|
||||
reason = Formulary.convert_to_deprecate_disable_reason_string_or_symbol json_formula["disable_reason"]
|
||||
disable! date: disable_date, because: reason
|
||||
end
|
||||
|
||||
json_formula["build_dependencies"].each do |dep|
|
||||
@ -201,7 +203,7 @@ module Formulary
|
||||
|
||||
@caveats_string = json_formula["caveats"]
|
||||
def caveats
|
||||
@caveats_string
|
||||
self.class.instance_variable_get(:@caveats_string)
|
||||
end
|
||||
end
|
||||
|
||||
@ -261,6 +263,12 @@ module Formulary
|
||||
string
|
||||
end
|
||||
|
||||
def self.convert_to_deprecate_disable_reason_string_or_symbol(string)
|
||||
return string unless DeprecateDisable::DEPRECATE_DISABLE_REASONS.keys.map(&:to_s).include?(string)
|
||||
|
||||
string.to_sym
|
||||
end
|
||||
|
||||
# A {FormulaLoader} returns instances of formulae.
|
||||
# Subclasses implement loaders for particular sources of formulae.
|
||||
class FormulaLoader
|
||||
|
||||
@ -241,7 +241,7 @@ describe Formulary do
|
||||
"recommended_dependencies" => ["recommended_dep"],
|
||||
"optional_dependencies" => ["optional_dep"],
|
||||
"uses_from_macos" => ["uses_from_macos_dep"],
|
||||
"caveats" => "",
|
||||
"caveats" => "example caveat string",
|
||||
}.merge(extra_items),
|
||||
}
|
||||
end
|
||||
@ -256,7 +256,7 @@ describe Formulary do
|
||||
let(:disable_json) do
|
||||
{
|
||||
"disable_date" => "2022-06-15",
|
||||
"disable_reason" => "repo_archived",
|
||||
"disable_reason" => "requires something else",
|
||||
}
|
||||
end
|
||||
|
||||
@ -276,6 +276,7 @@ describe Formulary do
|
||||
expect(formula.deps.count).to eq 5
|
||||
end
|
||||
expect(formula.uses_from_macos_elements).to eq ["uses_from_macos_dep"]
|
||||
expect(formula.caveats).to eq "example caveat string"
|
||||
expect {
|
||||
formula.install
|
||||
}.to raise_error("Cannot build from source from abstract formula.")
|
||||
@ -344,4 +345,25 @@ describe Formulary do
|
||||
.to eq(Pathname.new("#{HOMEBREW_LIBRARY}/Taps/homebrew/homebrew-core/Formula/#{name}.rb"))
|
||||
end
|
||||
end
|
||||
|
||||
describe "::convert_to_string_or_symbol" do
|
||||
it "returns the original string if it doesn't start with a colon" do
|
||||
expect(described_class.convert_to_string_or_symbol("foo")).to eq "foo"
|
||||
end
|
||||
|
||||
it "returns a symbol if the original string starts with a colon" do
|
||||
expect(described_class.convert_to_string_or_symbol(":foo")).to eq :foo
|
||||
end
|
||||
end
|
||||
|
||||
describe "::convert_to_deprecate_disable_reason_string_or_symbol" do
|
||||
it "returns the original string if it isn't a preset reason" do
|
||||
expect(described_class.convert_to_deprecate_disable_reason_string_or_symbol("foo")).to eq "foo"
|
||||
end
|
||||
|
||||
it "returns a symbol if the original string is a preset reason" do
|
||||
expect(described_class.convert_to_deprecate_disable_reason_string_or_symbol("does_not_build"))
|
||||
.to eq :does_not_build
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user