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


42
43
44
# File 'lib/octokit/default.rb', line 42

def access_token
  ENV['OCTOKIT_ACCESS_TOKEN']
end

.api_endpointString

Default API endpoint from ENV or API_ENDPOINT


48
49
50
# File 'lib/octokit/default.rb', line 48

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

.auto_paginateString

Default pagination preference from ENV


54
55
56
# File 'lib/octokit/default.rb', line 54

def auto_paginate
  ENV['OCTOKIT_AUTO_PAGINATE']
end

.client_idString

Default OAuth app key from ENV


60
61
62
# File 'lib/octokit/default.rb', line 60

def client_id
  ENV['OCTOKIT_CLIENT_ID']
end

.client_secretString

Default OAuth app secret from ENV


66
67
68
# File 'lib/octokit/default.rb', line 66

def client_secret
  ENV['OCTOKIT_SECRET']
end

.connection_optionsHash

Default options for Faraday::Connection


72
73
74
75
76
77
78
79
# File 'lib/octokit/default.rb', line 72

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

.default_media_typeString

Default media type from ENV or MEDIA_TYPE


83
84
85
# File 'lib/octokit/default.rb', line 83

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

.loginString

Default GitHub username for Basic Auth from ENV


89
90
91
# File 'lib/octokit/default.rb', line 89

def 
  ENV['OCTOKIT_LOGIN']
end

.middlewareString

Default middleware stack for Faraday::Connection from MIDDLEWARE


96
97
98
# File 'lib/octokit/default.rb', line 96

def middleware
  MIDDLEWARE
end

.netrcBoolean

Default behavior for reading .netrc file


134
135
136
# File 'lib/octokit/default.rb', line 134

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

.netrc_fileString

Default path for .netrc file


140
141
142
# File 'lib/octokit/default.rb', line 140

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

.optionsHash

Configuration options


36
37
38
# File 'lib/octokit/default.rb', line 36

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

.passwordString

Default GitHub password for Basic Auth from ENV


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

def password
  ENV['OCTOKIT_PASSWORD']
end

.per_pageFixnum

Default pagination page size from ENV


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

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


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

def proxy
  ENV['OCTOKIT_PROXY']
end

.user_agentString

Default User-Agent header string from ENV or USER_AGENT


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

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

.web_endpointString

Default web endpoint from ENV or WEB_ENDPOINT


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

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