123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::Server::ClientCommand::Exec Private

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base
Instance Chain:
self, Base
Inherits: RuboCop::Server::ClientCommand::Base
Defined in: lib/rubocop/server/client_command/exec.rb

Overview

This class is a client command to execute server process.

Instance Attribute Summary

Instance Method Summary

Base - Inherited

Instance Attribute Details

#incompatible_version?Boolean (readonly, private)

[ GitHub ]

  
# File 'lib/rubocop/server/client_command/exec.rb', line 43

def incompatible_version?
  Cache.version_path.read != Cache.restart_key
end

Instance Method Details

#ensure_server! (private)

[ GitHub ]

  
# File 'lib/rubocop/server/client_command/exec.rb', line 32

def ensure_server!
  if incompatible_version?
    warn 'RuboCop version incompatibility found, RuboCop server restarting...'
    ClientCommand::Stop.new.run
  elsif check_running_server
    return
  end

  ClientCommand::Start.new.run
end

#run

[ GitHub ]

  
# File 'lib/rubocop/server/client_command/exec.rb', line 18

def run
  ensure_server!
  read_stdin = ARGV.include?('-s') || ARGV.include?('--stdin')
  send_request(
    command: 'exec',
    args: ARGV.dup,
    body: read_stdin ? $stdin.read : ''
  )
  warn stderr unless stderr.empty?
  status
end

#status (private)

[ GitHub ]

  
# File 'lib/rubocop/server/client_command/exec.rb', line 51

def status
  unless Cache.status_path.file?
    raise "RuboCop server: Could not find status file at: #{Cache.status_path}"
  end

  status = Cache.status_path.read
  raise "RuboCop server: '#{status}' is not a valid status!" unless /\A\d+\z/.match?(status)

  status.to_i
end

#stderr (private)

[ GitHub ]

  
# File 'lib/rubocop/server/client_command/exec.rb', line 47

def stderr
  Cache.stderr_path.read
end