KegOnlyReason: print only the explanation if there’s one
Closes Homebrew/homebrew#42073. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
parent
ea13d62ce0
commit
ea08e4fb16
@ -23,28 +23,23 @@ class KegOnlyReason
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
return @explanation unless @explanation.empty?
|
||||||
case @reason
|
case @reason
|
||||||
when :provided_by_osx then <<-EOS
|
when :provided_by_osx then <<-EOS
|
||||||
OS X already provides this software and installing another version in
|
OS X already provides this software and installing another version in
|
||||||
parallel can cause all kinds of trouble.
|
parallel can cause all kinds of trouble.
|
||||||
|
|
||||||
#{@explanation}
|
|
||||||
EOS
|
EOS
|
||||||
when :shadowed_by_osx then <<-EOS
|
when :shadowed_by_osx then <<-EOS
|
||||||
OS X provides similar software, and installing this software in
|
OS X provides similar software, and installing this software in
|
||||||
parallel can cause all kinds of trouble.
|
parallel can cause all kinds of trouble.
|
||||||
|
|
||||||
#{@explanation}
|
|
||||||
EOS
|
EOS
|
||||||
when :provided_pre_mountain_lion then <<-EOS
|
when :provided_pre_mountain_lion then <<-EOS
|
||||||
OS X already provides this software in versions before Mountain Lion.
|
OS X already provides this software in versions before Mountain Lion.
|
||||||
|
|
||||||
#{@explanation}
|
|
||||||
EOS
|
EOS
|
||||||
when :provided_until_xcode43
|
when :provided_until_xcode43
|
||||||
"Xcode provides this software prior to version 4.3.\n\n#{@explanation}"
|
"Xcode provides this software prior to version 4.3."
|
||||||
when :provided_until_xcode5
|
when :provided_until_xcode5
|
||||||
"Xcode provides this software prior to version 5.\n\n#{@explanation}"
|
"Xcode provides this software prior to version 5."
|
||||||
else
|
else
|
||||||
@reason
|
@reason
|
||||||
end.strip
|
end.strip
|
||||||
|
13
Library/Homebrew/test/test_formula_support.rb
Normal file
13
Library/Homebrew/test/test_formula_support.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
require "testing_env"
|
||||||
|
|
||||||
|
class KegOnlyReasonTests < Homebrew::TestCase
|
||||||
|
def test_to_s_explanation
|
||||||
|
r = KegOnlyReason.new :provided_by_osx, "test"
|
||||||
|
assert_equal "test", r.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_to_s_no_explanation
|
||||||
|
r = KegOnlyReason.new :provided_by_osx, ""
|
||||||
|
assert_match(/^OS X already provides/, r.to_s)
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user