Module: Octokit::Default

Defined in:
lib/octokit/default.rb

Overview

Default configuration options for Client

Constant Summary

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 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

Returns:

  • (String)


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

def access_token
  ENV['OCTOKIT_ACCESS_TOKEN']
end

.api_endpointString

Default API endpoint from ENV or API_ENDPOINT

Returns:

  • (String)


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

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

.auto_paginateString

Default pagination preference from ENV

Returns:

  • (String)


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

def auto_paginate
  ENV['OCTOKIT_AUTO_PAGINATE']
end

.bearer_tokenString

Default bearer token from ENV

Returns:

  • (String)


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

def bearer_token
  ENV['OCTOKIT_BEARER_TOKEN']
end

.client_idString

Default OAuth app key from ENV

Returns:

  • (String)


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

def client_id
  ENV['OCTOKIT_CLIENT_ID']
end

.client_secretString

Default OAuth app secret from ENV

Returns:

  • (String)


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

def client_secret
  ENV['OCTOKIT_SECRET']
end

.connection_optionsHash

Default options for Faraday::Connection

Returns:

  • (Hash)


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

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

.default_media_typeString

Default media type from ENV or MEDIA_TYPE

Returns:

  • (String)


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

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

.loginString

Default GitHub username for Basic Auth from ENV

Returns:

  • (String)


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

def 
  ENV['OCTOKIT_LOGIN']
end

.management_console_endpointString

Default management console endpoint from ENV

Returns:

  • (String)


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

def management_console_endpoint
  ENV['OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT']
end

.management_console_passwordString

Default management console password from ENV

Returns:

  • (String)


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

def management_console_password
  ENV['OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD']
end

.middlewareFaraday::RackBuilder or Faraday::Builder

Default middleware stack for Faraday::Connection from MIDDLEWARE

Returns:

  • (Faraday::RackBuilder or Faraday::Builder)


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

def middleware
  MIDDLEWARE
end

.netrcBoolean

Default behavior for reading .netrc file

Returns:

  • (Boolean)


154
155
156
# File 'lib/octokit/default.rb', line 154

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

.netrc_fileString

Default path for .netrc file

Returns:

  • (String)


160
161
162
# File 'lib/octokit/default.rb', line 160

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

.optionsHash

Configuration options

Returns:

  • (Hash)


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

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

.passwordString

Default GitHub password for Basic Auth from ENV

Returns:

  • (String)


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

def password
  ENV['OCTOKIT_PASSWORD']
end

.per_pageInteger

Default pagination page size from ENV

Returns:

  • (Integer)

    Page size



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

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

Returns:

  • (String)


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

def proxy
  ENV['OCTOKIT_PROXY']
end

.user_agentString

Default User-Agent header string from ENV or USER_AGENT

Returns:

  • (String)


142
143
144
# File 'lib/octokit/default.rb', line 142

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

.web_endpointString

Default web endpoint from ENV or WEB_ENDPOINT

Returns:

  • (String)


148
149
150
# File 'lib/octokit/default.rb', line 148

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