Sha256: 92384dba0ea21aea0c641654e3306a6015449e94caca8525ee86d4aa5edb044f

Contents?: true

Size: 1.32 KB

Versions: 19

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require_relative 'platform'

#
# This code is based on https://github.com/fohte/rubocop-daemon.
#
# Copyright (c) 2018 Hayato Kawai
#
# The MIT License (MIT)
#
# https://github.com/fohte/rubocop-daemon/blob/master/LICENSE.txt
#
module RuboCop
  # The bootstrap module for server.
  # @api private
  module Server
    TIMEOUT = 20

    autoload :CLI, 'rubocop/server/cli'
    autoload :Cache, 'rubocop/server/cache'
    autoload :ClientCommand, 'rubocop/server/client_command'
    autoload :Helper, 'rubocop/server/helper'
    autoload :Core, 'rubocop/server/core'
    autoload :ServerCommand, 'rubocop/server/server_command'
    autoload :SocketReader, 'rubocop/server/socket_reader'

    class << self
      def support_server?
        RUBY_ENGINE == 'ruby' && !RuboCop::Platform.windows?
      end

      def running?
        return false unless support_server? # Never running.

        Cache.dir.exist? && Cache.pid_path.file? && Cache.pid_running?
      end

      def wait_for_running_status!(expected)
        start_time = Time.now
        while Server.running? != expected
          sleep 0.1
          next unless Time.now - start_time > TIMEOUT

          warn "running? was not #{expected} after #{TIMEOUT} seconds!"
          exit 1
        end
      end
    end
  end
end

require_relative 'server/errors'

Version data entries

19 entries across 15 versions & 3 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/server.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/server.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/server.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.31.2/lib/rubocop/server.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.35.1/lib/rubocop/server.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rubocop-1.36.0/lib/rubocop/server.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.31.2/lib/rubocop/server.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.35.1/lib/rubocop/server.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rubocop-1.36.0/lib/rubocop/server.rb
rubocop-1.36.0 lib/rubocop/server.rb
rubocop-1.35.1 lib/rubocop/server.rb
rubocop-1.35.0 lib/rubocop/server.rb
rubocop-1.34.1 lib/rubocop/server.rb
rubocop-1.34.0 lib/rubocop/server.rb
rubocop-1.33.0 lib/rubocop/server.rb
rubocop-1.32.0 lib/rubocop/server.rb
rubocop-1.31.2 lib/rubocop/server.rb
rubocop-1.31.1 lib/rubocop/server.rb
rubocop-1.31.0 lib/rubocop/server.rb