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.beta+json"
WEB_ENDPOINT =

Default WEB endpoint

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

Default Faraday middleware stack

Faraday::Builder.new do |builder|
  builder.use Octokit::Response::RaiseError
  builder.adapter Faraday.default_adapter
end

Class Method Summary collapse

Class Method Details

.access_tokenString

Default access token from ENV

Returns:

  • (String)


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

def access_token
  ENV['OCTOKIT_ACCESS_TOKEN']
end

.api_endpointString

Default API endpoint from ENV or API_ENDPOINT

Returns:

  • (String)


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

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

.auto_paginateString

Default pagination preference from ENV

Returns:

  • (String)


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

def auto_paginate
  ENV['OCTOKIT_AUTO_PAGINATE']
end

.client_idString

Default OAuth app key from ENV

Returns:

  • (String)


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

def client_id
  ENV['OCTOKIT_CLIENT_ID']
end

.client_secretString

Default OAuth app secret from ENV

Returns:

  • (String)


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

def client_secret
  ENV['OCTOKIT_SECRET']
end

.connection_optionsHash

Default options for Faraday::Connection

Returns:

  • (Hash)


67
68
69
70
71
72
73
74
# File 'lib/octokit/default.rb', line 67

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)


78
79
80
# File 'lib/octokit/default.rb', line 78

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

.loginString

Default GitHub username for Basic Auth from ENV

Returns:

  • (String)


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

def 
  ENV['OCTOKIT_LOGIN']
end

.middlewareString

Default middleware stack for Faraday::Connection from MIDDLEWARE

Returns:

  • (String)


91
92
93
# File 'lib/octokit/default.rb', line 91

def middleware
  MIDDLEWARE
end

.netrcBoolean

Default behavior for reading .netrc file

Returns:

  • (Boolean)


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

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

.netrc_fileString

Default path for .netrc file

Returns:

  • (String)


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

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

.optionsHash

Configuration options

Returns:

  • (Hash)


31
32
33
# File 'lib/octokit/default.rb', line 31

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

.passwordString

Default GitHub password for Basic Auth from ENV

Returns:

  • (String)


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

def password
  ENV['OCTOKIT_PASSWORD']
end

.per_pageFixnum

Default pagination page size from ENV

Returns:

  • (Fixnum)

    Page size



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

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)


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

def proxy
  ENV['OCTOKIT_PROXY']
end

.user_agentString

Default User-Agent header string from ENV or USER_AGENT

Returns:

  • (String)


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

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

.web_endpointString

Default web endpoint from ENV or WEB_ENDPOINT

Returns:

  • (String)


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

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