master/lib/guard/interactor.rb

41 lines
1.1 KiB
Ruby
Raw Normal View History

2010-10-03 21:00:33 +00:00
module Guard
module Interactor
2011-04-24 17:21:39 +00:00
def self.init_signal_traps
2010-10-03 21:00:33 +00:00
# Run all (Ctrl-\)
2011-04-24 17:21:39 +00:00
if Signal.list.has_key?('QUIT')
Signal.trap('QUIT') do
::Guard.run do
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :run_all) }
end
2010-10-03 21:00:33 +00:00
end
2011-04-24 17:21:39 +00:00
else
UI.info "Your system doesn't support QUIT signal, so Ctrl-\\ (Run all) won't work"
2010-10-03 21:00:33 +00:00
end
2011-04-24 17:21:39 +00:00
2010-10-03 21:00:33 +00:00
# Stop (Ctrl-C)
2011-04-24 17:21:39 +00:00
if Signal.list.has_key?('INT')
Signal.trap('INT') do
UI.info "Bye bye...", :reset => true
::Guard.listener.stop
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :stop) }
abort("\n")
end
else
UI.info "Your system doesn't support INT signal, so Ctrl-C (stop) won't work"
2010-10-03 21:00:33 +00:00
end
2011-04-24 17:21:39 +00:00
2010-10-03 21:00:33 +00:00
# Reload (Ctrl-Z)
2011-04-24 17:21:39 +00:00
if Signal.list.has_key?('TSTP')
Signal.trap('TSTP') do
::Guard.run do
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :reload) }
end
2010-10-03 21:00:33 +00:00
end
2011-04-24 17:21:39 +00:00
else
UI.info "Your system doesn't support TSTP signal, so Ctrl-Z (Reload) won't work"
2010-10-03 21:00:33 +00:00
end
end
2011-04-24 17:21:39 +00:00
2010-10-03 21:00:33 +00:00
end
end