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,33 +22,27 @@ module Guard
end end
def run_all def run_all
UI.info "Guard::JasmineHeadlessWebkit running all specs..." run_something_and_rescue do
JasmineHeadlessWebkitRunner.run if run_all_things_before UI.info "Guard::JasmineHeadlessWebkit running all specs..."
@ran_before = false JasmineHeadlessWebkitRunner.run if run_all_things_before
rescue ::CoffeeScript::CompilationError @ran_before = false
rescue StandardError => e end
puts e.message
puts e.backtrace.join("\n")
puts
end end
def run_on_change(paths) def run_on_change(paths)
paths = filter_paths(paths) run_something_and_rescue do
@ran_before = false paths = filter_paths(paths)
if run_all_things_before @ran_before = false
@ran_before = true if run_all_things_before
if !paths.empty? @ran_before = true
UI.info "Guard::JasmineHeadlessWebkit running the following: #{paths.join(' ')}" if !paths.empty?
JasmineHeadlessWebkitRunner.run(paths) UI.info "Guard::JasmineHeadlessWebkit running the following: #{paths.join(' ')}"
else JasmineHeadlessWebkitRunner.run(paths)
run_all else
run_all
end
end end
end end
rescue ::CoffeeScript::CompilationError
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