master/lib/guard/interactor.rb

32 lines
656 B
Ruby
Raw Normal View History

2010-10-03 21:00:33 +00:00
module Guard
module Interactor
def self.init_signal_traps
# Run all (Ctrl-\)
Signal.trap('QUIT') do
::Guard.run do
::Guard.guards.each(&:run_all)
end
end
# Stop (Ctrl-C)
Signal.trap('INT') do
::Guard.listener.stop
if ::Guard.guards.all?(&:stop)
UI.info "Bye bye...", :reset => true, :clear => false
abort("\n")
else
::Guard.listener.start
end
end
# Reload (Ctrl-Z)
Signal.trap('TSTP') do
::Guard.run do
::Guard.guards.each(&:reload)
end
end
end
end
end