master/lib/guard/interactor.rb

41 lines
716 B
Ruby
Raw Normal View History

2010-10-03 21:00:33 +00:00
module Guard
class Interactor
2011-09-01 21:24:45 +00:00
attr_reader :locked
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