Sha256: 78157db3af11b479f6a8a43c746854e6de2f6cff2b6ff49291cc10872d6377bd

Contents?: true

Size: 929 Bytes

Versions: 5

Compression:

Stored size: 929 Bytes

Contents

module Taric
  class Configuration
    attr_accessor :api_key, :format, :user_agent, :connection_opts, :adapter, :region, :requestor, :response_handler

    DEFAULT_REQUESTOR = -> connection, url {
      connection.get url
    }.curry

    DEFAULT_RESPONSE_HANDLER = -> response {
      response.body
    }

    def initialize(options = {})
      @api_key = options.fetch(:api_key, ENV.fetch('RIOT_API_KEY'.freeze, 'KeyNotSetButUsingThisForTest'.freeze))
      @format = options.fetch(:format, :json)
      @user_agent = options.fetch(:user_agent, 'Taric Gem')
      @adapter = options.fetch(:adapter, :typhoeus)
      @region = options.fetch(:region, ENV.fetch('RIOT_API_REGION'.freeze, 'na').to_sym)
      @connection_opts = options.fetch(:connection_opts, {})
      @requestor = options.fetch(:requestor, DEFAULT_REQUESTOR)
      @response_handler = options.fetch(:response_handler, DEFAULT_RESPONSE_HANDLER)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
taric-0.1.6 lib/taric/configuration.rb
taric-0.1.5 lib/taric/configuration.rb
taric-0.1.4 lib/taric/configuration.rb
taric-0.1.2 lib/taric/configuration.rb
taric-0.1.1 lib/taric/configuration.rb