class RuboCop::Server::ClientCommand::Base

Abstract base class for server client command. @api private

Public Instance Methods

run() click to toggle source
# File lib/rubocop/server/client_command/base.rb, line 21
def run
  raise NotImplementedError
end

Private Instance Methods

check_running_server() click to toggle source
# File lib/rubocop/server/client_command/base.rb, line 36
def check_running_server
  Server.running?.tap do |running|
    warn 'RuboCop server is not running.' unless running
  end
end
send_request(command:, args: [], body: '') click to toggle source
# File lib/rubocop/server/client_command/base.rb, line 27
def send_request(command:, args: [], body: '')
  TCPSocket.open('127.0.0.1', Cache.port_path.read) do |socket|
    socket.puts [Cache.token_path.read, Dir.pwd, command, *args].shelljoin
    socket.write body
    socket.close_write
    $stdout.write socket.readpartial(4096) until socket.eof?
  end
end