Sha256: 9fabdfc453367947f5dcb33c25b874f1b30838bc204014ea4c6afdc4317ebcd4

Contents?: true

Size: 1.53 KB

Versions: 4

Compression:

Stored size: 1.53 KB

Contents

require 'faraday'
require 'octokit/version'

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

    DEFAULT_ADAPTER        = Faraday.default_adapter
    DEFAULT_API_VERSION    = 3
    DEFAULT_API_ENDPOINT   = 'https://api.github.com/'
    DEFAULT_WEB_ENDPOINT   = 'https://github.com/'
    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 api_endpoint=(value)
      @api_endpoint = File.join(value, "")
    end

    def web_endpoint=(value)
      @web_endpoint = File.join(value, "")
    end

    def reset
      self.adapter        = DEFAULT_ADAPTER
      self.api_version    = DEFAULT_API_VERSION
      self.api_endpoint   = DEFAULT_API_ENDPOINT
      self.web_endpoint   = DEFAULT_WEB_ENDPOINT
      self.login          = nil
      self.password       = nil
      self.proxy          = nil
      self.oauth_token    = nil
      self.client_id      = nil
      self.client_secret  = nil
      self.user_agent     = DEFAULT_USER_AGENT
      self.auto_traversal = DEFAULT_AUTO_TRAVERSAL
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
octokit-1.15.0 lib/octokit/configuration.rb
octokit-1.14.0 lib/octokit/configuration.rb
octokit-1.13.0 lib/octokit/configuration.rb
octokit-1.12.0 lib/octokit/configuration.rb