Fix interacting with tools like ruby-debug.

It seems like the new interactor eats input from $stdin even while it locked.
  This disallow using tools like 'ruby-debug' or 'pry' in specs or cucumber.

  The fix just kills the interactor when it is locked and runs it again when
  ulocked.
This commit is contained in:
Aleksei Gusev 2011-09-19 23:27:05 +03:00
parent 22001c5ecd
commit 443f57efce

View File

@ -9,7 +9,7 @@ module Guard
def start
return if ENV["GUARD_ENV"] == 'test'
Thread.new do
@thread = Thread.new do
loop do
if (entry = $stdin.gets) && !@locked
entry.gsub! /\n/, ''
@ -28,12 +28,18 @@ module Guard
end
end
def stop
@thread.kill
end
def lock
@locked = true
stop
end
def unlock
@locked = false
start
end
end