2010-10-03 21:00:33 +00:00
|
|
|
module Guard
|
|
|
|
class Guard
|
2011-04-14 20:53:53 +00:00
|
|
|
include Hook
|
|
|
|
|
2010-10-03 21:00:33 +00:00
|
|
|
attr_accessor :watchers, :options
|
2011-01-19 22:05:45 +00:00
|
|
|
|
2010-10-03 21:00:33 +00:00
|
|
|
def initialize(watchers = [], options = {})
|
|
|
|
@watchers, @options = watchers, options
|
|
|
|
end
|
2011-01-19 22:05:45 +00:00
|
|
|
|
2010-10-07 20:37:30 +00:00
|
|
|
# Guardfile template needed inside guard gem
|
|
|
|
def self.init(name)
|
2010-12-17 17:37:24 +00:00
|
|
|
if ::Guard::Dsl.guardfile_include?(name)
|
2010-10-07 20:37:30 +00:00
|
|
|
::Guard::UI.info "Guardfile already include #{name} guard"
|
|
|
|
else
|
|
|
|
content = File.read('Guardfile')
|
|
|
|
guard = File.read("#{::Guard.locate_guard(name)}/lib/guard/#{name}/templates/Guardfile")
|
|
|
|
File.open('Guardfile', 'wb') do |f|
|
2010-11-25 23:58:36 +00:00
|
|
|
f.puts(content)
|
|
|
|
f.puts("")
|
|
|
|
f.puts(guard)
|
2010-10-07 20:37:30 +00:00
|
|
|
end
|
|
|
|
::Guard::UI.info "#{name} guard added to Guardfile, feel free to edit it"
|
|
|
|
end
|
|
|
|
end
|
2011-01-19 22:05:45 +00:00
|
|
|
|
2010-10-03 21:00:33 +00:00
|
|
|
# ================
|
|
|
|
# = Guard method =
|
|
|
|
# ================
|
2011-01-19 22:05:45 +00:00
|
|
|
|
2010-10-27 20:14:21 +00:00
|
|
|
# Call once when guard starts
|
|
|
|
# Please override initialize method to init stuff
|
2010-10-03 21:00:33 +00:00
|
|
|
def start
|
|
|
|
true
|
|
|
|
end
|
2011-01-19 22:05:45 +00:00
|
|
|
|
2010-10-27 20:14:21 +00:00
|
|
|
# Call once when guard quit
|
2010-10-03 21:00:33 +00:00
|
|
|
def stop
|
|
|
|
true
|
|
|
|
end
|
2011-01-19 22:05:45 +00:00
|
|
|
|
2010-10-27 20:14:21 +00:00
|
|
|
# Should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
|
2010-10-03 21:00:33 +00:00
|
|
|
def reload
|
|
|
|
true
|
|
|
|
end
|
2011-01-19 22:05:45 +00:00
|
|
|
|
2010-10-27 20:14:21 +00:00
|
|
|
# Should be principally used for long action like running all specs/tests/...
|
2010-10-03 21:00:33 +00:00
|
|
|
def run_all
|
|
|
|
true
|
|
|
|
end
|
2011-01-19 22:05:45 +00:00
|
|
|
|
2010-10-03 21:00:33 +00:00
|
|
|
def run_on_change(paths)
|
|
|
|
true
|
|
|
|
end
|
2011-01-19 22:05:45 +00:00
|
|
|
|
2010-10-03 21:00:33 +00:00
|
|
|
end
|
|
|
|
end
|