From ea08e4fb16b7f9ffc66b267d532bcdea4f513f0b Mon Sep 17 00:00:00 2001 From: Baptiste Fontaine <batifon@yahoo.fr> Date: Fri, 24 Jul 2015 00:49:34 +0200 Subject: [PATCH] =?UTF-8?q?KegOnlyReason:=20print=20only=20the=20explanati?= =?UTF-8?q?on=20if=20there=E2=80=99s=20one?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes Homebrew/homebrew#42073. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr> --- Library/Homebrew/formula_support.rb | 11 +++-------- Library/Homebrew/test/test_formula_support.rb | 13 +++++++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 Library/Homebrew/test/test_formula_support.rb diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index 6813c1faa2..f6bb000bc2 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -23,28 +23,23 @@ class KegOnlyReason end def to_s + return @explanation unless @explanation.empty? case @reason when :provided_by_osx then <<-EOS OS X already provides this software and installing another version in parallel can cause all kinds of trouble. - -#{@explanation} EOS when :shadowed_by_osx then <<-EOS OS X provides similar software, and installing this software in parallel can cause all kinds of trouble. - -#{@explanation} EOS when :provided_pre_mountain_lion then <<-EOS OS X already provides this software in versions before Mountain Lion. - -#{@explanation} EOS 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 - "Xcode provides this software prior to version 5.\n\n#{@explanation}" + "Xcode provides this software prior to version 5." else @reason end.strip diff --git a/Library/Homebrew/test/test_formula_support.rb b/Library/Homebrew/test/test_formula_support.rb new file mode 100644 index 0000000000..08d10292f2 --- /dev/null +++ b/Library/Homebrew/test/test_formula_support.rb @@ -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 -- GitLab