2010-10-03 21:00:33 +00:00
|
|
|
module Guard
|
|
|
|
module Interactor
|
2011-05-06 17:29:24 +00:00
|
|
|
extend self
|
|
|
|
|
2011-08-13 14:43:32 +00:00
|
|
|
def listen
|
|
|
|
return if ENV["GUARD_ENV"] == 'test'
|
|
|
|
if entry = $stdin.readline
|
|
|
|
entry.gsub! /\n/, ''
|
|
|
|
case entry
|
|
|
|
when 'quit', 'exit', 'q', 'e'
|
|
|
|
UI.info "Bye bye...", :reset => true
|
|
|
|
::Guard.listener.stop
|
|
|
|
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :stop) }
|
|
|
|
abort
|
|
|
|
when 'reload', 'r', 'z'
|
|
|
|
::Guard.run do
|
|
|
|
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :reload) }
|
|
|
|
end
|
|
|
|
listen
|
|
|
|
else # run_all
|
|
|
|
::Guard.run do
|
|
|
|
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :run_all) }
|
|
|
|
end
|
|
|
|
listen
|
2010-10-03 21:00:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-08-13 14:43:32 +00:00
|
|
|
|
|
|
|
# def run_all
|
|
|
|
# ::Guard.run do
|
|
|
|
# ::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :run_all) }
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# def stop
|
|
|
|
# UI.info "Bye bye...", :reset => true
|
|
|
|
# ::Guard.listener.stop
|
|
|
|
# ::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :stop) }
|
|
|
|
# abort
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# def reload
|
|
|
|
# ::Guard.run do
|
|
|
|
# ::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :reload) }
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# def self.init_signal_traps
|
|
|
|
# # Run all (Ctrl-\)
|
|
|
|
# if Signal.list.has_key?('QUIT')
|
|
|
|
# Signal.trap('QUIT') do
|
|
|
|
# run_all
|
|
|
|
# end
|
|
|
|
# else
|
|
|
|
# UI.info "Your system doesn't support QUIT signal, so Ctrl-\\ (Run all) won't work"
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# # Stop (Ctrl-C)
|
|
|
|
# if Signal.list.has_key?('INT')
|
|
|
|
# Signal.trap('INT') do
|
|
|
|
# stop
|
|
|
|
# end
|
|
|
|
# else
|
|
|
|
# UI.info "Your system doesn't support INT signal, so Ctrl-C (Stop) won't work"
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# # Reload (Ctrl-Z)
|
|
|
|
# if Signal.list.has_key?('TSTP')
|
|
|
|
# Signal.trap('TSTP') do
|
|
|
|
# reload
|
|
|
|
# end
|
|
|
|
# else
|
|
|
|
# UI.info "Your system doesn't support TSTP signal, so Ctrl-Z (Reload) won't work"
|
|
|
|
# end
|
|
|
|
#
|
|
|
|
# end
|
2010-10-03 21:00:33 +00:00
|
|
|
end
|
2011-05-06 17:29:24 +00:00
|
|
|
end
|