Module: Octokit::Configuration

Included in:
Octokit
Defined in:
lib/octokit/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
:adapter,
:faraday_config_block,
:api_version,
:api_endpoint,
:web_endpoint,
:status_api_endpoint,
:login,
:password,
:proxy,
:oauth_token,
:client_id,
:client_secret,
:user_agent,
:request_host,
:netrc,
:auto_traversal,
:per_page].freeze
DEFAULT_ADAPTER =
Faraday.default_adapter
DEFAULT_API_VERSION =
3
DEFAULT_API_ENDPOINT =
ENV['OCTOKIT_API_ENDPOINT'] || 'https://api.github.com/'
DEFAULT_WEB_ENDPOINT =
ENV['OCTOKIT_WEB_ENDPOINT'] || 'https://github.com/'
DEFAULT_STATUS_API_ENDPOINT =
ENV['OCTOKIT_STATUS_API_ENDPOINT'] || 'https://status.github.com/api/'
DEFAULT_USER_AGENT =
"Octokit Ruby Gem #{Octokit::VERSION}".freeze
DEFAULT_AUTO_TRAVERSAL =
false

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



35
36
37
# File 'lib/octokit/configuration.rb', line 35

def self.extended(base)
  base.reset
end

Instance Method Details

#api_endpoint=(value) ⇒ Object



47
48
49
# File 'lib/octokit/configuration.rb', line 47

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

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



39
40
41
# File 'lib/octokit/configuration.rb', line 39

def configure
  yield self
end

#faraday_config(&block) ⇒ Object



55
56
57
# File 'lib/octokit/configuration.rb', line 55

def faraday_config(&block)
  @faraday_config_block = block
end

#optionsObject



43
44
45
# File 'lib/octokit/configuration.rb', line 43

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

#resetObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/octokit/configuration.rb', line 59

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.status_api_endpoint = DEFAULT_STATUS_API_ENDPOINT
  self.               = nil
  self.password            = nil
  self.proxy               = nil
  self.oauth_token         = nil
  self.client_id           = nil
  self.client_secret       = nil
  self.request_host        = nil
  self.netrc               = false
  self.user_agent          = DEFAULT_USER_AGENT
  self.auto_traversal      = DEFAULT_AUTO_TRAVERSAL
end

#web_endpoint=(value) ⇒ Object



51
52
53
# File 'lib/octokit/configuration.rb', line 51

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