module RubyInspector

Constants

DELIMITER
VERSION

Attributes

app_name[RW]
description[RW]

Public Class Methods

disable() click to toggle source
# File lib/ruby_inspector.rb, line 24
def disable
  @socket = nil
  @initialized = nil
end
enable(app_name, description) click to toggle source
# File lib/ruby_inspector.rb, line 9
def enable(app_name, description)
  @app_name = app_name
  @description = description

  begin
    send_init_info
  rescue Errno::ECONNREFUSED
    puts "[RubyInspector] Unable to send initialization info during setup"
  end

  ::Nsa::NetHttpTracker.on_request do |net_http_request_tracker|
    DevToolsRequestTracker.new(net_http_request_tracker)
  end
end
send_info(data) click to toggle source
# File lib/ruby_inspector.rb, line 29
def send_info(data)
  send_init_info unless initialized?
  send_socket_msg(data)
rescue Errno::ECONNREFUSED
  puts "[RubyInspector] Unable to send data: #{data}"
end

Private Class Methods

initialized?() click to toggle source
# File lib/ruby_inspector.rb, line 40
def initialized?
  @initialized
end
send_init_info() click to toggle source
# File lib/ruby_inspector.rb, line 54
def send_init_info
  send_socket_msg(
    method: "RubyInspector.initialize",
    params: {
      name: app_name,
      type: :ruby,
      description: description
    }
  )
  @initialized = true
end
send_socket_msg(data) click to toggle source
# File lib/ruby_inspector.rb, line 48
def send_socket_msg(data)
  socket.puts(
    ::JSON.generate(data) + DELIMITER
  )
end
socket() click to toggle source
# File lib/ruby_inspector.rb, line 44
def socket
  @socket ||= TCPSocket.new("localhost", 8124)
end