From 443f57efce8876d73e6c954783e62c16f3f43f22 Mon Sep 17 00:00:00 2001 From: Aleksei Gusev Date: Mon, 19 Sep 2011 23:27:05 +0300 Subject: [PATCH] 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. --- lib/guard/interactor.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/guard/interactor.rb b/lib/guard/interactor.rb index 5c5fd09..0abbb5a 100644 --- a/lib/guard/interactor.rb +++ b/lib/guard/interactor.rb @@ -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