Sha256: 60840cfd4014a4af4faaa39170d4ebf2e70f16e584d89c7e22b3b8e13f2615a4

Contents?: true

Size: 1.02 KB

Versions: 201

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

#
# 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
  module Server
    module ServerCommand
      # Abstract base class for server command.
      # @api private
      class Base
        # Common functionality for working with subclasses of this class.
        # @api private
        module Runner
          def run
            validate_token!
            Dir.chdir(@cwd) do
              super
            end
          end
        end

        def self.inherited(child)
          super
          child.prepend Runner
        end

        def initialize(args, token: '', cwd: Dir.pwd)
          @args = args
          @token = token
          @cwd = cwd
        end

        def run; end

        private

        def validate_token!
          raise InvalidTokenError unless Cache.token_path.read == @token
        end
      end
    end
  end
end

Version data entries

201 entries across 194 versions & 20 rubygems

Version Path
rubocop-1.74.0 lib/rubocop/server/server_command/base.rb
rubocop-1.73.2 lib/rubocop/server/server_command/base.rb
siteimprove_api_client-1.0.1 vendor/bundle/ruby/3.2.0/gems/rubocop-1.73.1/lib/rubocop/server/server_command/base.rb
rubocop-1.73.1 lib/rubocop/server/server_command/base.rb
rubocop-1.73.0 lib/rubocop/server/server_command/base.rb
rubocop-1.72.2 lib/rubocop/server/server_command/base.rb
rubocop-1.72.1 lib/rubocop/server/server_command/base.rb
rubocop-1.72.0 lib/rubocop/server/server_command/base.rb
rubocop-1.71.2 lib/rubocop/server/server_command/base.rb
tailscale_middleware-0.0.3 vendor/cache/ruby/3.4.0/gems/rubocop-1.71.1/lib/rubocop/server/server_command/base.rb
rubocop-1.71.1 lib/rubocop/server/server_command/base.rb
rubocop-1.71.0 lib/rubocop/server/server_command/base.rb
rubocop-1.70.0 lib/rubocop/server/server_command/base.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/server/server_command/base.rb
rubocop-1.69.2 lib/rubocop/server/server_command/base.rb
rubocop-1.69.1 lib/rubocop/server/server_command/base.rb
rubocop-1.69.0 lib/rubocop/server/server_command/base.rb
rubocop-1.68.0 lib/rubocop/server/server_command/base.rb
rubocop-1.67.0 lib/rubocop/server/server_command/base.rb
rubocop-1.66.1 lib/rubocop/server/server_command/base.rb