Class SporkDebugger::EachRunState
In: lib/spork/ext/ruby-debug.rb
Parent: Object

Methods

Included Modules

NetworkHelpers

Public Class methods

[Source]

# File lib/spork/ext/ruby-debug.rb, line 106
    def initialize(connection_request_port)
      @connection_request_port = connection_request_port
    end

Public Instance methods

[Source]

# File lib/spork/ext/ruby-debug.rb, line 110
    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

[Source]

# File lib/spork/ext/ruby-debug.rb, line 119
    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

[Source]

# File lib/spork/ext/ruby-debug.rb, line 126
    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

[Source]

# File lib/spork/ext/ruby-debug.rb, line 138
      def wait_for_connection
        while Debugger.handler.interface.nil?; sleep 0.10; end
      end

[Validate]