Sha256: 02b565be54a1967d4b4b80e77ff6bf6f30567fbbb7d15bb60f6fabc004a9dd82

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Bundler
  module Alive
    module Client
      #
      # Represents a source code client
      #
      class SourceCodeClient
        # Error of searching repository
        class SearchRepositoryError < StandardError
        end

        # Error of rate limit exceeded
        class RateLimitExceededError < StandardError
        end

        SERVICE_WITH_STRATEGIES = {
          SourceCodeRepository::Service::GITHUB => GitHubApi
        }.freeze

        private_constant :SERVICE_WITH_STRATEGIES

        #
        # A new instance of SourceCodeClient
        #
        # @param [Symbol] service_name
        #
        # @raise [ArgumentError]
        #
        # @return [SourceCodeClient]
        #
        def initialize(service_name:)
          raise ArgumentError, "Unknown service: #{service_name}" unless SERVICE_WITH_STRATEGIES.key?(service_name)

          strategy = SERVICE_WITH_STRATEGIES[service_name]
          extend strategy

          @client = create_client
          @error_messages = []

          super()
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bundler-alive-0.1.5 lib/bundler/alive/client/source_code_client.rb
bundler-alive-0.1.4 lib/bundler/alive/client/source_code_client.rb
bundler-alive-0.1.3 lib/bundler/alive/client/source_code_client.rb