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

- (Object) access_token

Returns the value of attribute access_token



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

def access_token
  @access_token
end

- (String) api_endpoint

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

Returns:



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

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

- (Boolean) auto_paginate

Returns Auto fetch next page of results until rate limit reached

Returns:

  • (Boolean)

    Auto fetch next page of results until rate limit reached



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

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

- (String) client_id

Returns Configure OAuth app key

Returns:

  • (String)

    Configure OAuth app key

See Also:



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

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

- (Object) client_secret

Returns the value of attribute client_secret



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

def client_secret
  @client_secret
end

- (Hash) connection_options

Returns Configure connection options for Faraday

Returns:

  • (Hash)

    Configure connection options for Faraday

See Also:



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

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

- (String) default_media_type

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

Returns:

  • (String)

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

See Also:



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

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

- (String) login

Returns GitHub username for Basic Authentication

Returns:

  • (String)

    GitHub username for Basic Authentication



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

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

- (String) management_console_endpoint

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



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

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

- (String) management_console_password

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



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

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

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

Returns Configure middleware for Faraday

Returns:

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

    Configure middleware for Faraday

See Also:



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

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

- (Boolean) netrc

Returns Instruct Octokit to get credentials from .netrc file

Returns:

  • (Boolean)

    Instruct Octokit to get credentials from .netrc file



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

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

- (String) netrc_file

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

Returns:

  • (String)

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



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

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

- (String) password=(value) (writeonly)

Returns GitHub password for Basic Authentication

Returns:

  • (String)

    GitHub password for Basic Authentication



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

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

- (String) per_page

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

Returns:

  • (String)

    Configure page size for paginated results. API default: 30



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

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

- (String) proxy

Returns URI for proxy server

Returns:

  • (String)

    URI for proxy server

See Also:



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

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

- (String) user_agent

Returns Configure User-Agent header for requests.

Returns:

  • (String)

    Configure User-Agent header for requests.



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

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

- (String) web_endpoint

Base URL for generated web URLs

Returns:



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

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

Class Method Details

+ (Array) keys

List of configurable keys for Octokit::Client

Returns:

  • (Array)

    of option keys



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

def keys
  @keys ||= [
    :access_token,
    :api_endpoint,
    :auto_paginate,
    :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

- (Object) configure {|_self| ... }

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:



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

def configure
  yield self
end

- (Boolean) netrc?

Returns:

  • (Boolean)


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

def netrc?
  !!@netrc
end

- (Object) reset! Also known as: setup

Reset configuration options to default values



91
92
93
94
95
96
# File 'lib/octokit/configurable.rb', line 91

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

- (Boolean) same_options?(opts)

Compares client options to a Hash of requested options

Parameters:

  • opts (Hash)

    Options to compare with current client options

Returns:

  • (Boolean)


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

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