guard-jasmine-headless-webkit/lib/guard/jasmine-headless-webkit.rb
2011-05-23 20:44:18 -04:00

36 lines
725 B
Ruby

require 'guard'
require 'guard/guard'
module Guard
class JasmineHeadlessWebkit < Guard
def initialize(watchers = [], options = {})
super
@options = {
:all_on_start => true
}.merge(options)
end
def start
UI.info "Guard::JasmineHeadlessWebkit is running."
run_all if @options[:all_on_start]
end
def run_all
system %{jasmine-headless-webkit}
end
def run_on_change(paths)
system %{jasmine-headless-webkit #{paths.join(" ")}}
run_all if $?.exitstatus != 1
end
end
class DSL
def matching_js_file(path)
Dir[path + '*.{js,coffee}'].sort { |left, right| File.mtime(right) <=> File.mtime(left) }.first
end
end
end