Class: RuboCop::Server::SocketReader Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/server/socket_reader.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This class sends the request read from the socket to server.

Defined Under Namespace

Classes: Header, Request

Instance Method Summary collapse

Constructor Details

#initialize(socket) ⇒ SocketReader

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SocketReader.



20
21
22
# File 'lib/rubocop/server/socket_reader.rb', line 20

def initialize(socket)
  @socket = socket
end

Instance Method Details

#read!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rubocop/server/socket_reader.rb', line 24

def read!
  request = parse_request(@socket.read)

  stderr = StringIO.new
  Helper.redirect(
    stdin: StringIO.new(request.body),
    stdout: @socket,
    stderr: stderr
  ) do
    create_command_instance(request).run
  end
ensure
  Cache.stderr_path.write(stderr.string)
  @socket.close
end