Skip to content

Commit

Permalink
Fix interacting with tools like ruby-debug.
Browse files Browse the repository at this point in the history
  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.
  • Loading branch information
hron committed Sep 19, 2011
1 parent 22001c5 commit 443f57e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/guard/interactor.rb
Expand Up @@ -9,7 +9,7 @@ def initialize

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/, ''
Expand All @@ -28,12 +28,18 @@ def start
end
end

def stop
@thread.kill
end

def lock
@locked = true
stop
end

def unlock
@locked = false
start
end

end
Expand Down

0 comments on commit 443f57e

Please sign in to comment.