Remove prefix option and add reason argument name
This commit is contained in:
parent
9e35b4de21
commit
fb3bfbb65c
@ -2920,21 +2920,12 @@ 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? :default_prefix_required</pre>
|
# <pre>pour_bottle? reason: :clt_required</pre>
|
||||||
# <pre>pour_bottle? :clt_required</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)
|
||||||
|
|
||||||
block ||= case requirement
|
if reason == :clt_required
|
||||||
when :default_prefix_required
|
block = lambda do |_|
|
||||||
lambda do |_|
|
|
||||||
T.cast(self, PourBottleCheck).reason(+<<~EOS)
|
|
||||||
The bottle needs to be installed into #{Homebrew::DEFAULT_PREFIX}.
|
|
||||||
EOS
|
|
||||||
T.cast(self, PourBottleCheck).satisfy { HOMEBREW_PREFIX.to_s == Homebrew::DEFAULT_PREFIX }
|
|
||||||
end
|
|
||||||
when :clt_required
|
|
||||||
lambda do |_|
|
|
||||||
on_macos do
|
on_macos do
|
||||||
T.cast(self, PourBottleCheck).reason(+<<~EOS)
|
T.cast(self, PourBottleCheck).reason(+<<~EOS)
|
||||||
The bottle needs the Apple Command Line Tools to be installed.
|
The bottle needs the Apple Command Line Tools to be installed.
|
||||||
|
|||||||
@ -997,26 +997,26 @@ describe Formula do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when set with a symbol" do
|
it "returns false when set with a symbol" do
|
||||||
# Ensure that prefix does not match the default
|
# Pretend CLT is not installed
|
||||||
stub_const "Homebrew::DEFAULT_PREFIX", "foo"
|
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? :default_prefix_required
|
pour_bottle? reason: :clt_required
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(f).not_to pour_bottle
|
expect(f).not_to pour_bottle
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns true when set with a symbol" do
|
it "returns true when set with a symbol" do
|
||||||
# Ensure that prefix matches the default
|
# Pretend CLT is installed
|
||||||
stub_const "Homebrew::DEFAULT_PREFIX", HOMEBREW_PREFIX.to_s
|
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? :default_prefix_required
|
pour_bottle? reason: :clt_required
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(f).to pour_bottle
|
expect(f).to pour_bottle
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user