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

Methods

Included Modules

NetworkHelpers

External Aliases

debugger -> debugger_without_spork_hook

Public Class methods

[Source]

# File lib/spork/ext/ruby-debug.rb, line 46
    def initialize
      install_hook
      listen_for_connection_signals
    end

Public Instance methods

[Source]

# File lib/spork/ext/ruby-debug.rb, line 51
    def finish
      @tcp_service.close; @tcp_service = nil;
    end

[Source]

# File lib/spork/ext/ruby-debug.rb, line 55
    def transition_to_each_run_state
      finish
      SporkDebugger::EachRunState.new(@port)
    end

Protected Instance methods

[Source]

# File lib/spork/ext/ruby-debug.rb, line 94
      def connect_rdebug_client(port = Debugger::PORT)
        puts "\n\n - Debug Session Started - \n\n\n"
        begin
          Debugger.start_client(SporkDebugger::HOST, port)
        rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ECONNREFUSED
        end
        puts "\n\n - Debug Session Terminated - \n\n\n"
      end

[Source]

# File lib/spork/ext/ruby-debug.rb, line 64
          def debugger(steps = 1)
            SporkDebugger.instance.prepare_debugger
            debugger_without_spork_hook
          end

[Source]

# File lib/spork/ext/ruby-debug.rb, line 61
      def install_hook
        Kernel.class_eval do
          alias :debugger_without_spork_hook :debugger
          def debugger(steps = 1)
            SporkDebugger.instance.prepare_debugger
            debugger_without_spork_hook
          end
        end
      end

[Source]

# File lib/spork/ext/ruby-debug.rb, line 71
      def listen_for_connection_signals
        @port = SporkDebugger::DEFAULT_PORT
        begin
          @tcp_service = TCPServer.new(SporkDebugger::HOST, @port)
        rescue Errno::EADDRINUSE
          @port += 1
          retry
        end
        Thread.new { main_loop }
      end

[Source]

# File lib/spork/ext/ruby-debug.rb, line 82
      def main_loop
        while @tcp_service do
          socket = @tcp_service.accept
          port = Marshal.load(socket)
          Marshal.dump(true, socket)
          connect_rdebug_client(port)
          socket.close
        end
      rescue => e
        puts "error: #{e.class} - #{e}"
      end

[Validate]