Sha256: a1c78e901380dd5cf5980c0b11d2161fc4568309faa15a2995e6c7c5a908376b

Contents?: true

Size: 1.28 KB

Versions: 171

Compression:

Stored size: 1.28 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.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

171 entries across 170 versions & 17 rubygems

Version Path
rubocop-1.71.0 lib/rubocop/server.rb
rubocop-1.70.0 lib/rubocop/server.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/server.rb
rubocop-1.69.2 lib/rubocop/server.rb
rubocop-1.69.1 lib/rubocop/server.rb
rubocop-1.69.0 lib/rubocop/server.rb
rubocop-1.68.0 lib/rubocop/server.rb
rubocop-1.67.0 lib/rubocop/server.rb
rubocop-1.66.1 lib/rubocop/server.rb
rubocop-1.66.0 lib/rubocop/server.rb
rubocop-1.65.1 lib/rubocop/server.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/server.rb
rubocop-1.65.0 lib/rubocop/server.rb
katalyst-govuk-formbuilder-1.9.2 vendor/bundle/ruby/3.3.0/gems/rubocop-1.64.1/lib/rubocop/server.rb
rubocop-1.64.1 lib/rubocop/server.rb
rubocop-1.63.4 lib/rubocop/server.rb
rubocop-1.63.3 lib/rubocop/server.rb
rubocop-1.63.2 lib/rubocop/server.rb
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/server.rb
rubocop-1.63.1 lib/rubocop/server.rb