class SporkDebugger::EachRunState

Public Instance Methods

prepare_debugger() click to toggle source
# File lib/spork/ext/ruby-debug.rb, line 112
def prepare_debugger
  return if @debugger_prepared
  @debugger_prepared = true
  port, cport = start_rdebug_server
  signal_spork_server_to_connect_to_rdebug_server(port)
  wait_for_connection
  puts "\n\n - breakpoint - see your spork server for the debug terminal - \n\n"
end
signal_spork_server_to_connect_to_rdebug_server(rdebug_server_port) click to toggle source
# File lib/spork/ext/ruby-debug.rb, line 121
def signal_spork_server_to_connect_to_rdebug_server(rdebug_server_port)
  socket = TCPSocket.new(SporkDebugger::HOST, @connection_request_port)
  Marshal.dump(rdebug_server_port, socket)
  response = Marshal.load(socket)
  socket.close
end
start_rdebug_server() click to toggle source
# File lib/spork/ext/ruby-debug.rb, line 128
def start_rdebug_server
  Debugger.stop if Debugger.started?
  port = find_port(Debugger::PORT)
  cport = find_port(port + 1)
  Debugger.start_remote(SporkDebugger::HOST, [port, cport]) do
    Debugger.run_init_script(StringIO.new)
  end
  Debugger.start
  [port, cport]
end

Protected Instance Methods

wait_for_connection() click to toggle source
# File lib/spork/ext/ruby-debug.rb, line 140
def wait_for_connection
  while Debugger.handler.interface.nil?; sleep 0.10; end
end

Public Class Methods

new(connection_request_port) click to toggle source
# File lib/spork/ext/ruby-debug.rb, line 108
def initialize(connection_request_port)
  @connection_request_port = connection_request_port
end