Sha256: 638280edca3e87498dae1da693e8f321837e050e1041ff4ec89c81287813c704

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

require_relative 'version'

module HN
  module Configuration

    VALID_CONFIGURATION_KEYS = [:api_version, :base_url, :api_url, :headers]

    attr_accessor *VALID_CONFIGURATION_KEYS

    DEFAULT_VERSION  = 'v0'
    DEFAULT_BASE_URL = 'https://hacker-news.firebaseio.com'
    DEFAULT_API_URL  = "#{DEFAULT_BASE_URL}/#{DEFAULT_VERSION}/"
    DEFAULT_HEADERS  = { accept:     'application/json',
                         user_agent: "hn_api gem #{HN::Version}" }

    def configure
      yield self
    end

    def reset
      self.api_version = DEFAULT_VERSION
      self.base_url    = DEFAULT_BASE_URL
      self.api_url     = DEFAULT_API_URL
      self.headers     = DEFAULT_HEADERS
      self
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hn_api-0.0.1 lib/hn/configuration.rb