Module: Octokit::Configurable

Included in:
Octokit, Client, EnterpriseAdminClient, EnterpriseManagementConsoleClient
Defined in:
lib/octokit/configurable.rb

Overview

Configuration options for Client, defaulting to values in Default

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



53
54
55
# File 'lib/octokit/configurable.rb', line 53

def access_token
  @access_token
end

#api_endpointString

Returns Base URL for API requests. default: api.github.com/.

Returns:



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#auto_paginateBoolean

Returns Auto fetch next page of results until rate limit reached.

Returns:

  • (Boolean)

    Auto fetch next page of results until rate limit reached



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#bearer_tokenObject

Returns the value of attribute bearer_token.



53
54
55
# File 'lib/octokit/configurable.rb', line 53

def bearer_token
  @bearer_token
end

#client_idString

Returns Configure OAuth app key.

Returns:

  • (String)

    Configure OAuth app key

See Also:



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#client_secretObject

Returns the value of attribute client_secret.



53
54
55
# File 'lib/octokit/configurable.rb', line 53

def client_secret
  @client_secret
end

#connection_optionsHash

Returns Configure connection options for Faraday.

Returns:

  • (Hash)

    Configure connection options for Faraday

See Also:



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#default_media_typeString

Returns Configure preferred media type (for API versioning, for example).

Returns:

  • (String)

    Configure preferred media type (for API versioning, for example)

See Also:



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#loginString

Returns GitHub username for Basic Authentication.

Returns:

  • (String)

    GitHub username for Basic Authentication



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#management_console_endpointString

Returns Base URL for API requests to the GitHub Enterprise management console.

Returns:

  • (String)

    Base URL for API requests to the GitHub Enterprise management console



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#management_console_passwordString

Returns An admin password set up for your GitHub Enterprise management console.

Returns:

  • (String)

    An admin password set up for your GitHub Enterprise management console



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#middlewareFaraday::Builder or Faraday::RackBuilder

Returns Configure middleware for Faraday.

Returns:

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

    Configure middleware for Faraday

See Also:



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#netrcBoolean

Returns Instruct Octokit to get credentials from .netrc file.

Returns:

  • (Boolean)

    Instruct Octokit to get credentials from .netrc file



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#netrc_fileString

Returns Path to .netrc file. default: ~/.netrc.

Returns:

  • (String)

    Path to .netrc file. default: ~/.netrc



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#password=(value) ⇒ String (writeonly)

Returns GitHub password for Basic Authentication.

Returns:

  • (String)

    GitHub password for Basic Authentication



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#per_pageString

Returns Configure page size for paginated results. API default: 30.

Returns:

  • (String)

    Configure page size for paginated results. API default: 30



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#proxyString

Returns URI for proxy server.

Returns:

  • (String)

    URI for proxy server

See Also:



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#user_agentString

Returns Configure User-Agent header for requests.

Returns:

  • (String)

    Configure User-Agent header for requests.



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

#web_endpointString

Base URL for generated web URLs

Returns:



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

attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
:client_secret, :default_media_type, :connection_options,
:middleware, :netrc, :netrc_file,
:per_page, :proxy, :user_agent

Class Method Details

.keysArray

List of configurable keys for Octokit::Client

Returns:

  • (Array)

    of option keys



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/octokit/configurable.rb', line 64

def keys
  @keys ||= [
    :access_token,
    :api_endpoint,
    :auto_paginate,
    :bearer_token,
    :client_id,
    :client_secret,
    :connection_options,
    :default_media_type,
    :login,
    :management_console_endpoint,
    :management_console_password,
    :middleware,
    :netrc,
    :netrc_file,
    :per_page,
    :password,
    :proxy,
    :user_agent,
    :web_endpoint
  ]
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:



90
91
92
# File 'lib/octokit/configurable.rb', line 90

def configure
  yield self
end

#netrc?Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/octokit/configurable.rb', line 132

def netrc?
  !!@netrc
end

#reset!Object Also known as: setup

Reset configuration options to default values



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

def reset!
  Octokit::Configurable.keys.each do |key|
    instance_variable_set(:"@#{key}", Octokit::Default.options[key])
  end
  self
end

#same_options?(opts) ⇒ Boolean

Compares client options to a Hash of requested options

Parameters:

  • opts (Hash)

    Options to compare with current client options

Returns:

  • (Boolean)


107
108
109
# File 'lib/octokit/configurable.rb', line 107

def same_options?(opts)
  opts.hash == options.hash
end