Sha256: 79552792ddf4f09373e65f1b76e6aecd4fda066c6f6fe4298d89f822205daecb

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 KB

Contents

require 'faraday'
require 'octokit/version'

module Octokit
  module Configuration
    VALID_OPTIONS_KEYS = [
      :adapter,
      :api_version,
      :login,
      :password,
      :proxy,
      :oauth_token,
      :user_agent,
      :auto_traversal,
      :per_page].freeze

    DEFAULT_ADAPTER        = Faraday.default_adapter
    DEFAULT_API_VERSION    = 3
    DEFAULT_USER_AGENT     = "Octokit Ruby Gem #{Octokit::VERSION}".freeze
    DEFAULT_AUTO_TRAVERSAL = false

    attr_accessor(*VALID_OPTIONS_KEYS)

    def self.extended(base)
      base.reset
    end

    def configure
      yield self
    end

    def options
      VALID_OPTIONS_KEYS.inject({}){|o,k| o.merge!(k => send(k)) }
    end

    def reset
      self.adapter        = DEFAULT_ADAPTER
      self.api_version    = DEFAULT_API_VERSION
      self.login          = nil
      self.password       = nil
      self.proxy          = nil
      self.oauth_token    = nil
      self.user_agent     = DEFAULT_USER_AGENT
      self.auto_traversal = DEFAULT_AUTO_TRAVERSAL
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
octokit-1.5.0 lib/octokit/configuration.rb
octokit-1.4.0 lib/octokit/configuration.rb
octokit-1.3.0 lib/octokit/configuration.rb
octokit-1.2.1 lib/octokit/configuration.rb
octokit-1.2.0 lib/octokit/configuration.rb
octokit-1.1.1 lib/octokit/configuration.rb
octokit-1.1.0 lib/octokit/configuration.rb
octokit-1.0.7 lib/octokit/configuration.rb