From 45e208d26b52413efc0bb1dd598bf33c326d5023 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Tue, 6 Nov 2012 17:32:23 -0600 Subject: [PATCH] Move conflict message into conflict class --- Library/Homebrew/formula.rb | 14 +------------- Library/Homebrew/requirements.rb | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 03d9dde62f..a76740ef7c 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -721,19 +721,7 @@ private end def conflicts_with formula, opts={} - message = <<-EOS.undent - #{formula} cannot be installed alongside #{name.downcase}. - EOS - message << "This is because #{opts[:because]}\n" if opts[:because] - unless ARGV.force? then message << <<-EOS.undent - Please `brew unlink #{formula}` before continuing. Unlinking removes - the formula's symlinks from #{HOMEBREW_PREFIX}. You can link the - formula again after the install finishes. You can --force this install - but the build may fail or cause obscure side-effects in the end-binary. - EOS - end - - dependencies.add ConflictRequirement.new(formula, message) + dependencies.add ConflictRequirement.new(formula, name, opts) end def skip_clean *paths diff --git a/Library/Homebrew/requirements.rb b/Library/Homebrew/requirements.rb index 00c1612969..7f1a02da81 100644 --- a/Library/Homebrew/requirements.rb +++ b/Library/Homebrew/requirements.rb @@ -177,12 +177,23 @@ end class ConflictRequirement < Requirement attr_reader :formula - def initialize formula, message + def initialize formula, name, opts={} @formula = formula - @message = message + @name = name + @opts = opts end - def message; @message; end + def message + message = "#{@name.downcase} cannot be installed alongside #{@formula}.\n" + message << "This is because #{@opts[:because]}\n" if @opts[:because] + message << <<-EOS.undent unless ARGV.force? + Please `brew unlink #{@formula}` before continuing. Unlinking removes + the formula's symlinks from #{HOMEBREW_PREFIX}. You can link the + formula again after the install finishes. You can --force this install + but the build may fail or cause obscure side-effects in the end-binary. + EOS + message + end def satisfied? keg = Formula.factory(@formula).prefix