class RuboCop::Daemon::ClientCommand::Base
Public Class Methods
new(argv)
click to toggle source
# File lib/rubocop/daemon/client_command/base.rb, line 10 def initialize(argv) @argv = argv.dup @options = {} end
Public Instance Methods
run()
click to toggle source
# File lib/rubocop/daemon/client_command/base.rb, line 15 def run; end
Private Instance Methods
check_running_server()
click to toggle source
# File lib/rubocop/daemon/client_command/base.rb, line 28 def check_running_server Daemon.running?.tap do |running| warn 'rubocop-daemon: server is not running.' unless running end end
ensure_server!()
click to toggle source
# File lib/rubocop/daemon/client_command/base.rb, line 34 def ensure_server! return if check_running_server ClientCommand::Start.new([]).run end
send_request(command:, args: [], body: '')
click to toggle source
# File lib/rubocop/daemon/client_command/base.rb, line 19 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.read(4096) until socket.eof? end end