master/lib/guard/interactor.rb

39 lines
691 B
Ruby
Raw Normal View History

2010-10-03 21:00:33 +00:00
module Guard
class Interactor
def initialize
@locked = false
end
2011-08-17 08:07:30 +00:00
def start
return if ENV["GUARD_ENV"] == 'test'
2011-08-17 08:07:30 +00:00
Thread.new do
loop do
if (entry = $stdin.gets) && !@locked
entry.gsub! /\n/, ''
case entry
when 'stop', 'quit', 'exit', 's', 'q', 'e'
::Guard.stop
when 'reload', 'r', 'z'
::Guard.reload
when 'pause', 'p'
::Guard.pause
else
::Guard.run_all
2011-08-17 08:07:30 +00:00
end
end
2010-10-03 21:00:33 +00:00
end
end
end
def lock
@locked = true
end
def unlock
@locked = false
2011-08-17 08:07:30 +00:00
end
2010-10-03 21:00:33 +00:00
end
end