Move exceptions from global to utils; remove duplicate defintions

This commit is contained in:
Adam Vandenberg 2010-07-06 11:48:36 -07:00
parent 6b1a8be58e
commit 696e49e87a
3 changed files with 36 additions and 75 deletions

View File

@ -41,40 +41,3 @@ HOMEBREW_USER_AGENT = "Homebrew #{HOMEBREW_VERSION} (Ruby #{RUBY_VERSION}-#{RUBY
RECOMMENDED_LLVM = 2206
RECOMMENDED_GCC_40 = 5493
RECOMMENDED_GCC_42 = (MACOS_VERSION >= 10.6) ? 5646 : 5577
class ExecutionError <RuntimeError
attr :exit_status
attr :command
def initialize cmd, args = [], es = nil
@command = cmd
super "Failure while executing: #{cmd} #{pretty(args)*' '}"
@exit_status = es.exitstatus rescue 1
end
def was_running_configure?
@command == './configure'
end
private
def pretty args
args.collect do |arg|
if arg.to_s.include? ' '
"'#{ arg.gsub "'", "\\'" }'"
else
arg
end
end
end
end
class BuildError <ExecutionError
attr :env
def initialize cmd, args = [], es = nil
super
@env = ENV.to_hash
end
end

View File

@ -26,42 +26,4 @@ at_exit { HOMEBREW_PREFIX.parent.rmtree }
# Test fixtures and files can be found relative to this path
TEST_FOLDER = Pathname.new(ABS__FILE__).parent.realpath
# Note: These exceptions duplicate those defined in globals.
# Perhaps the same definitions should be used in both places.
class ExecutionError <RuntimeError
attr :exit_status
attr :command
def initialize cmd, args = [], es = nil
@command = cmd
super "Failure while executing: #{cmd} #{pretty(args)*' '}"
@exit_status = es.exitstatus rescue 1
end
def was_running_configure?
@command == './configure'
end
private
def pretty args
args.collect do |arg|
if arg.to_s.include? ' '
"'#{ arg.gsub "'", "\\'" }'"
else
arg
end
end
end
end
class BuildError <ExecutionError
attr :env
def initialize cmd, args = [], es = nil
super
@env = ENV.to_hash
end
end
require 'test/unit' # must be after at_exit

View File

@ -1,3 +1,39 @@
class ExecutionError <RuntimeError
attr :exit_status
attr :command
def initialize cmd, args = [], es = nil
@command = cmd
super "Failure while executing: #{cmd} #{pretty(args)*' '}"
@exit_status = es.exitstatus rescue 1
end
def was_running_configure?
@command == './configure'
end
private
def pretty args
args.collect do |arg|
if arg.to_s.include? ' '
"'#{ arg.gsub "'", "\\'" }'"
else
arg
end
end
end
end
class BuildError <ExecutionError
attr :env
def initialize cmd, args = [], es = nil
super
@env = ENV.to_hash
end
end
class Tty
class <<self
def blue; bold 34; end