Sha256: d1bae0e651ad4bb82826479c0729d4a6e048556459f81561eaed9e48e9eec78b

Contents?: true

Size: 997 Bytes

Versions: 3

Compression:

Stored size: 997 Bytes

Contents

# frozen_string_literal: true

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

        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)

          service = SERVICE_WITH_STRATEGIES[service_name]
          extend service

          @client = create_client

          super()
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bundler-alive-0.1.2 lib/bundler/alive/client/source_code_client.rb
bundler-alive-0.1.1 lib/bundler/alive/client/source_code_client.rb
bundler-alive-0.1.0 lib/bundler/alive/client/source_code_client.rb