master/lib/guard/guard.rb

57 lines
1.3 KiB
Ruby
Raw Normal View History

2010-10-03 21:00:33 +00:00
module Guard
class Guard
attr_accessor :watchers, :options, :group
def initialize(watchers = [], options = {}, group = nil)
2010-10-03 21:00:33 +00:00
@watchers, @options = watchers, options
@group ||= :default
2010-10-03 21:00:33 +00:00
end
2010-10-07 20:37:30 +00:00
# Guardfile template needed inside guard gem
def self.init(name)
if ::Guard::Dsl.guardfile_include?(name)
2011-08-02 10:03:15 +00:00
::Guard::UI.info "Guardfile already includes #{name} guard"
2010-10-07 20:37:30 +00:00
else
content = File.read('Guardfile')
guard = File.read("#{::Guard.locate_guard(name)}/lib/guard/#{name}/templates/Guardfile")
File.open('Guardfile', 'wb') do |f|
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
2010-10-03 21:00:33 +00:00
# ================
# = Guard method =
# ================
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
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
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
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
2010-10-03 21:00:33 +00:00
def run_on_change(paths)
true
end
2010-10-03 21:00:33 +00:00
end
end