Module: Octokit::Default

Defined in:
lib/octokit/default.rb

Overview

Default configuration options for Client

Constant Summary collapse

API_ENDPOINT =

Default API endpoint

"https://api.github.com".freeze
USER_AGENT =

Default User Agent header string

"Octokit Ruby Gem #{Octokit::VERSION}".freeze
MEDIA_TYPE =

Default media type

"application/vnd.github.v3+json".freeze
WEB_ENDPOINT =

Default WEB endpoint

"https://github.com".freeze
RACK_BUILDER_CLASS =

In Faraday 0.9, Faraday::Builder was renamed to Faraday::RackBuilder

defined?(Faraday::RackBuilder) ? Faraday::RackBuilder : Faraday::Builder
MIDDLEWARE =

Default Faraday middleware stack

RACK_BUILDER_CLASS.new do |builder|
  builder.use Faraday::Request::Retry, exceptions: [Octokit::ServerError]
  builder.use Octokit::Middleware::FollowRedirects
  builder.use Octokit::Response::RaiseError
  builder.use Octokit::Response::FeedParser
  builder.adapter Faraday.default_adapter
end

Class Method Summary collapse

Class Method Details

.access_tokenString

Default access token from ENV


45
46
47
# File 'lib/octokit/default.rb', line 45

def access_token
  ENV['OCTOKIT_ACCESS_TOKEN']
end

.api_endpointString

Default API endpoint from ENV or API_ENDPOINT


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

def api_endpoint
  ENV['OCTOKIT_API_ENDPOINT'] || API_ENDPOINT
end

.auto_paginateString

Default pagination preference from ENV


57
58
59
# File 'lib/octokit/default.rb', line 57

def auto_paginate
  ENV['OCTOKIT_AUTO_PAGINATE']
end

.bearer_tokenString

Default bearer token from ENV


63
64
65
# File 'lib/octokit/default.rb', line 63

def bearer_token
  ENV['OCTOKIT_BEARER_TOKEN']
end

.client_idString

Default OAuth app key from ENV


69
70
71
# File 'lib/octokit/default.rb', line 69

def client_id
  ENV['OCTOKIT_CLIENT_ID']
end

.client_secretString

Default OAuth app secret from ENV


75
76
77
# File 'lib/octokit/default.rb', line 75

def client_secret
  ENV['OCTOKIT_SECRET']
end

.connection_optionsHash

Default options for Faraday::Connection


93
94
95
96
97
98
99
100
# File 'lib/octokit/default.rb', line 93

def connection_options
  {
    :headers => {
      :accept => default_media_type,
      :user_agent => user_agent
    }
  }
end

.default_media_typeString

Default media type from ENV or MEDIA_TYPE


104
105
106
# File 'lib/octokit/default.rb', line 104

def default_media_type
  ENV['OCTOKIT_DEFAULT_MEDIA_TYPE'] || MEDIA_TYPE
end

.loginString

Default GitHub username for Basic Auth from ENV


110
111
112
# File 'lib/octokit/default.rb', line 110

def 
  ENV['OCTOKIT_LOGIN']
end

.management_console_endpointString

Default management console endpoint from ENV


87
88
89
# File 'lib/octokit/default.rb', line 87

def management_console_endpoint
  ENV['OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT']
end

.management_console_passwordString

Default management console password from ENV


81
82
83
# File 'lib/octokit/default.rb', line 81

def management_console_password
  ENV['OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD']
end

.middlewareFaraday::RackBuilder or Faraday::Builder

Default middleware stack for Faraday::Connection from MIDDLEWARE


117
118
119
# File 'lib/octokit/default.rb', line 117

def middleware
  MIDDLEWARE
end

.netrcBoolean

Default behavior for reading .netrc file


164
165
166
# File 'lib/octokit/default.rb', line 164

def netrc
  ENV['OCTOKIT_NETRC'] || false
end

.netrc_fileString

Default path for .netrc file


170
171
172
# File 'lib/octokit/default.rb', line 170

def netrc_file
  ENV['OCTOKIT_NETRC_FILE'] || File.join(ENV['HOME'].to_s, '.netrc')
end

.optionsHash

Configuration options


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

def options
  Hash[Octokit::Configurable.keys.map{|key| [key, send(key)]}]
end

.passwordString

Default GitHub password for Basic Auth from ENV


123
124
125
# File 'lib/octokit/default.rb', line 123

def password
  ENV['OCTOKIT_PASSWORD']
end

.per_pageInteger

Default pagination page size from ENV


129
130
131
132
133
# File 'lib/octokit/default.rb', line 129

def per_page
  page_size = ENV['OCTOKIT_PER_PAGE']

  page_size.to_i if page_size
end

.proxyString

Default proxy server URI for Faraday connection from ENV


137
138
139
# File 'lib/octokit/default.rb', line 137

def proxy
  ENV['OCTOKIT_PROXY']
end

.ssl_verify_modeInteger

Default SSL verify mode from ENV


143
144
145
146
147
148
# File 'lib/octokit/default.rb', line 143

def ssl_verify_mode
  # 0 is OpenSSL::SSL::VERIFY_NONE
  # 1 is OpenSSL::SSL::SSL_VERIFY_PEER
  # the standard default for SSL is SSL_VERIFY_PEER which requires a server certificate check on the client
  ENV.fetch('OCTOKIT_SSL_VERIFY_MODE', 1).to_i
end

.user_agentString

Default User-Agent header string from ENV or USER_AGENT


152
153
154
# File 'lib/octokit/default.rb', line 152

def user_agent
  ENV['OCTOKIT_USER_AGENT'] || USER_AGENT
end

.web_endpointString

Default web endpoint from ENV or WEB_ENDPOINT


158
159
160
# File 'lib/octokit/default.rb', line 158

def web_endpoint
  ENV['OCTOKIT_WEB_ENDPOINT'] || WEB_ENDPOINT
end