Sha256: 4b6f742018345918b1935a564069ef41f0e4a69e1c3352ed181542152bd06226

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 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,
          SourceCodeRepository::Service::GITLAB => GitlabApi
        }.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

2 entries across 2 versions & 1 rubygems

Version Path
bundler-alive-0.1.7 lib/bundler/alive/client/source_code_client.rb
bundler-alive-0.1.6 lib/bundler/alive/client/source_code_client.rb