formula: tweak preset pour_bottle? symbols
Let's rename `reason` to `requirement` so the preset symbol can just be `:clt`. See Homebrew/homebrew-core#77509.
This commit is contained in:
parent
2e9d4ffa15
commit
3c34c13056
@ -2920,16 +2920,16 @@ class Formula
|
|||||||
# the {Formula} will be built from source and `reason` will be printed.
|
# the {Formula} will be built from source and `reason` will be printed.
|
||||||
#
|
#
|
||||||
# Alternatively, a preset reason can be passed as a symbol:
|
# Alternatively, a preset reason can be passed as a symbol:
|
||||||
# <pre>pour_bottle? reason: :clt_required</pre>
|
# <pre>pour_bottle? requirement: :clt</pre>
|
||||||
def pour_bottle?(reason: nil, &block)
|
def pour_bottle?(requirement: nil, &block)
|
||||||
@pour_bottle_check = PourBottleCheck.new(self)
|
@pour_bottle_check = PourBottleCheck.new(self)
|
||||||
|
|
||||||
if reason.present? && block.present?
|
if requirement.present? && block.present?
|
||||||
raise ArgumentError, "Do not pass both a reason and a block to `pour_bottle?`"
|
raise ArgumentError, "Do not pass both a requirement and a block to `pour_bottle?`"
|
||||||
end
|
end
|
||||||
|
|
||||||
block ||= case reason
|
block ||= case requirement
|
||||||
when :clt_required
|
when :clt
|
||||||
lambda do |_|
|
lambda do |_|
|
||||||
on_macos do
|
on_macos do
|
||||||
T.cast(self, PourBottleCheck).reason(+<<~EOS)
|
T.cast(self, PourBottleCheck).reason(+<<~EOS)
|
||||||
@ -2941,7 +2941,7 @@ class Formula
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
raise ArgumentError, "Invalid `pour_bottle?` reason" if reason.present?
|
raise ArgumentError, "Invalid `pour_bottle?` requirement" if requirement.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
@pour_bottle_check.instance_eval(&block)
|
@pour_bottle_check.instance_eval(&block)
|
||||||
|
|||||||
@ -996,37 +996,37 @@ describe Formula do
|
|||||||
expect(f).to pour_bottle
|
expect(f).to pour_bottle
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false with `reason: :clt_required` on macOS", :needs_macos do
|
it "returns false with `requirement: :clt` on macOS", :needs_macos do
|
||||||
# Pretend CLT is not installed
|
# Pretend CLT is not installed
|
||||||
allow(MacOS::CLT).to receive(:installed?).and_return(false)
|
allow(MacOS::CLT).to receive(:installed?).and_return(false)
|
||||||
|
|
||||||
f = formula "foo" do
|
f = formula "foo" do
|
||||||
url "foo-1.0"
|
url "foo-1.0"
|
||||||
|
|
||||||
pour_bottle? reason: :clt_required
|
pour_bottle? requirement: :clt
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(f).not_to pour_bottle
|
expect(f).not_to pour_bottle
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true with `reason: :clt_required` on macOS", :needs_macos do
|
it "returns true with `requirement: :clt` on macOS", :needs_macos do
|
||||||
# Pretend CLT is installed
|
# Pretend CLT is installed
|
||||||
allow(MacOS::CLT).to receive(:installed?).and_return(true)
|
allow(MacOS::CLT).to receive(:installed?).and_return(true)
|
||||||
|
|
||||||
f = formula "foo" do
|
f = formula "foo" do
|
||||||
url "foo-1.0"
|
url "foo-1.0"
|
||||||
|
|
||||||
pour_bottle? reason: :clt_required
|
pour_bottle? requirement: :clt
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(f).to pour_bottle
|
expect(f).to pour_bottle
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true with `reason: :clt_required` on Linux", :needs_linux do
|
it "returns true with `requirement: :clt` on Linux", :needs_linux do
|
||||||
f = formula "foo" do
|
f = formula "foo" do
|
||||||
url "foo-1.0"
|
url "foo-1.0"
|
||||||
|
|
||||||
pour_bottle? reason: :clt_required
|
pour_bottle? requirement: :clt
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(f).to pour_bottle
|
expect(f).to pour_bottle
|
||||||
@ -1037,12 +1037,12 @@ describe Formula do
|
|||||||
formula "foo" do
|
formula "foo" do
|
||||||
url "foo-1.0"
|
url "foo-1.0"
|
||||||
|
|
||||||
pour_bottle? reason: :clt_required do
|
pour_bottle? requirement: :clt do
|
||||||
reason "true reason"
|
reason "true reason"
|
||||||
satisfy { true }
|
satisfy { true }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end.to raise_error(ArgumentError, "Do not pass both a reason and a block to `pour_bottle?`")
|
end.to raise_error(ArgumentError, "Do not pass both a requirement and a block to `pour_bottle?`")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "throws an error if passed an invalid symbol" do
|
it "throws an error if passed an invalid symbol" do
|
||||||
@ -1050,9 +1050,9 @@ describe Formula do
|
|||||||
formula "foo" do
|
formula "foo" do
|
||||||
url "foo-1.0"
|
url "foo-1.0"
|
||||||
|
|
||||||
pour_bottle? reason: :foo
|
pour_bottle? requirement: :foo
|
||||||
end
|
end
|
||||||
end.to raise_error(ArgumentError, "Invalid `pour_bottle?` reason")
|
end.to raise_error(ArgumentError, "Invalid `pour_bottle?` requirement")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user