Sha256: 94efc575988616e5a919ccf259bb52e7c9240cb04c4b58b5e0675daf4a72ba0d

Contents?: true

Size: 1.14 KB

Versions: 12

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require "socket"

module Byebug
  module Remote
    #
    # Client for remote debugging
    #
    class Client
      attr_reader :interface, :socket

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

      #
      # Connects to the remote byebug
      #
      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

      def started?
        !socket.nil?
      end

      private

      def connect_at(host, port)
        interface.puts "Connecting to byebug server at #{host}:#{port}..."
        @socket = TCPSocket.new(host, port)
        interface.puts "Connected."
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 5 rubygems

Version Path
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/byebug-10.0.2/lib/byebug/remote/client.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/byebug-10.0.2/lib/byebug/remote/client.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/byebug-10.0.2/lib/byebug/remote/client.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/byebug-10.0.2/lib/byebug/remote/client.rb
jets-0.5.5 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/remote/client.rb
jets-0.5.4 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/remote/client.rb
jets-0.5.3 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/remote/client.rb
jets-0.5.2 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/remote/client.rb
jets-0.5.1 vendor/lambdagem/bundled/gems/ruby/2.5.0/gems/byebug-10.0.0/lib/byebug/remote/client.rb
byebug-10.0.2 lib/byebug/remote/client.rb
byebug-10.0.1 lib/byebug/remote/client.rb
byebug-10.0.0 lib/byebug/remote/client.rb