master/lib/guard/interactor.rb
Thibaud Guillaume-Gentil 3717179591 Refactor new interactor/listener mechanic now it's
look pretty.
Specs still need some love :)
2011-08-30 21:13:51 +02:00

39 lines
691 B
Ruby

module Guard
class Interactor
def initialize
@locked = false
end
def start
return if ENV["GUARD_ENV"] == 'test'
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
end
end
end
end
end
def lock
@locked = true
end
def unlock
@locked = false
end
end
end