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

+ (String) access_token

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

+ (String) api_endpoint

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

+ (String) auto_paginate

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

+ (String) client_id

Default OAuth app key from ENV

Returns:

  • (String)


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

def client_id
  ENV['OCTOKIT_CLIENT_ID']
end

+ (String) client_secret

Default OAuth app secret from ENV

Returns:

  • (String)


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

def client_secret
  ENV['OCTOKIT_SECRET']
end

+ (Hash) connection_options

Default options for Faraday::Connection

Returns:

  • (Hash)


86
87
88
89
90
91
92
93
# File 'lib/octokit/default.rb', line 86

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

+ (String) default_media_type

Default media type from ENV or MEDIA_TYPE

Returns:

  • (String)


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

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

+ (String) login

Default GitHub username for Basic Auth from ENV

Returns:

  • (String)


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

def 
  ENV['OCTOKIT_LOGIN']
end

+ (String) management_console_endpoint

Default management console endpoint from ENV

Returns:

  • (String)


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

def management_console_endpoint
  ENV['OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT']
end

+ (String) management_console_password

Default management console password from ENV

Returns:

  • (String)


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

def management_console_password
  ENV['OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD']
end

+ (Faraday::RackBuilder or Faraday::Builder) middleware

Default middleware stack for Faraday::Connection from MIDDLEWARE

Returns:

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


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

def middleware
  MIDDLEWARE
end

+ (Boolean) netrc

Default behavior for reading .netrc file

Returns:

  • (Boolean)


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

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

+ (String) netrc_file

Default path for .netrc file

Returns:

  • (String)


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

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

+ (Hash) options

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

+ (String) password

Default GitHub password for Basic Auth from ENV

Returns:

  • (String)


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

def password
  ENV['OCTOKIT_PASSWORD']
end

+ (Fixnum) per_page

Default pagination page size from ENV

Returns:

  • (Fixnum)

    Page size



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

def per_page
  page_size = ENV['OCTOKIT_PER_PAGE']

  page_size.to_i if page_size
end

+ (String) proxy

Default proxy server URI for Faraday connection from ENV

Returns:

  • (String)


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

def proxy
  ENV['OCTOKIT_PROXY']
end

+ (String) user_agent

Default User-Agent header string from ENV or USER_AGENT

Returns:

  • (String)


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

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

+ (String) web_endpoint

Default web endpoint from ENV or WEB_ENDPOINT

Returns:

  • (String)


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

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