Class: Byebug::Remote::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/byebug/remote/client.rb

Overview

Client for remote debugging

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(interface) ⇒ Client

Returns a new instance of Client.



13
14
15
16
# File 'lib/byebug/remote/client.rb', line 13

def initialize(interface)
  @interface = interface
  @socket = nil
end

Instance Attribute Details

#interfaceObject (readonly)

Returns the value of attribute interface.



11
12
13
# File 'lib/byebug/remote/client.rb', line 11

def interface
  @interface
end

#socketObject (readonly)

Returns the value of attribute socket.



11
12
13
# File 'lib/byebug/remote/client.rb', line 11

def socket
  @socket
end

Instance Method Details

#start(host = "localhost", port = PORT) ⇒ Object

Connects to the remote byebug



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/byebug/remote/client.rb', line 21

def start(host = "localhost", port = PORT)
  connect_at(host, port)

  while (line = socket.gets)
    case line
    when /^PROMPT (.*)$/
      input = interface.read_command(Regexp.last_match[1])
      break unless input

      socket.puts input
    when /^CONFIRM (.*)$/
      input = interface.readline(Regexp.last_match[1])
      break unless input

      socket.puts input
    else
      interface.puts line
    end
  end

  socket.close
end

#started?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/byebug/remote/client.rb', line 44

def started?
  !socket.nil?
end