master/lib/guard/guard.rb

55 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
def initialize(watchers = [], options = {})
@watchers, @options = watchers, options
end
2010-10-07 20:37:30 +00:00
# Guardfile template needed inside guard gem
def self.init(name)
if ::Guard::Dsl.guardfile_included?(name)
::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|
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
def run_on_change(paths)
true
end
end
end