2010-10-03 21:00:33 +00:00
|
|
|
module Guard
|
2011-09-20 11:10:16 +00:00
|
|
|
|
|
|
|
# The interactor reads user input and triggers
|
|
|
|
# specific action upon them unless its locked.
|
|
|
|
#
|
|
|
|
# Currently the following actions are implemented:
|
2011-09-20 22:34:11 +00:00
|
|
|
#
|
2011-09-20 11:10:16 +00:00
|
|
|
# - stop, quit, exit, s, q, e => Exit Guard
|
|
|
|
# - reload, r, z => Reload Guard
|
|
|
|
# - pause, p => Pause Guard
|
|
|
|
# - Everything else => Run all
|
|
|
|
#
|
2011-08-30 19:13:51 +00:00
|
|
|
class Interactor
|
2011-05-06 17:29:24 +00:00
|
|
|
|
2011-09-20 22:34:11 +00:00
|
|
|
# Start the interactor in its own thread.
|
2011-09-20 11:10:16 +00:00
|
|
|
#
|
2011-08-30 19:13:51 +00:00
|
|
|
def start
|
2011-08-13 14:43:32 +00:00
|
|
|
return if ENV["GUARD_ENV"] == 'test'
|
2011-09-20 11:10:16 +00:00
|
|
|
|
2011-09-19 20:27:05 +00:00
|
|
|
@thread = Thread.new do
|
2011-10-01 01:45:41 +00:00
|
|
|
while entry = $stdin.gets.chomp
|
|
|
|
entry.gsub! /\n/, ''
|
|
|
|
case entry
|
|
|
|
when 'stop', 'quit', 'exit', 's', 'q', 'e'
|
|
|
|
::Guard.stop
|
|
|
|
when 'reload', 'r', 'z'
|
|
|
|
::Guard::Dsl.reevaluate_guardfile
|
|
|
|
::Guard.reload
|
|
|
|
when 'pause', 'p'
|
|
|
|
::Guard.pause
|
|
|
|
else
|
|
|
|
::Guard.run_all
|
2011-08-13 14:43:32 +00:00
|
|
|
end
|
2010-10-03 21:00:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-05-06 17:29:24 +00:00
|
|
|
end
|