refactor something that was really starting to bug me

This commit is contained in:
John Bintz 2011-06-26 16:13:33 -04:00
parent 7ca6900570
commit 245eeba260
1 changed files with 25 additions and 22 deletions

View File

@ -22,17 +22,15 @@ module Guard
end end
def run_all def run_all
run_something_and_rescue do
UI.info "Guard::JasmineHeadlessWebkit running all specs..." UI.info "Guard::JasmineHeadlessWebkit running all specs..."
JasmineHeadlessWebkitRunner.run if run_all_things_before JasmineHeadlessWebkitRunner.run if run_all_things_before
@ran_before = false @ran_before = false
rescue ::CoffeeScript::CompilationError end
rescue StandardError => e
puts e.message
puts e.backtrace.join("\n")
puts
end end
def run_on_change(paths) def run_on_change(paths)
run_something_and_rescue do
paths = filter_paths(paths) paths = filter_paths(paths)
@ran_before = false @ran_before = false
if run_all_things_before if run_all_things_before
@ -44,11 +42,7 @@ module Guard
run_all run_all
end end
end end
rescue ::CoffeeScript::CompilationError end
rescue StandardError => e
puts e.message
puts e.backtrace.join("\n")
puts
end end
private private
@ -91,6 +85,15 @@ module Guard
system command system command
$?.exitstatus == 0 $?.exitstatus == 0
end end
def run_something_and_rescue
yield
rescue ::CoffeeScript::CompilationError
rescue StandardError => e
puts e.message
puts e.backtrace.join("\n")
puts
end
end end
class Dsl class Dsl