123456789_123456789_123456789_123456789_123456789_

Module: Octokit::Configurable

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Extended In:
Included In:
Defined in: lib/octokit/configurable.rb

Overview

Configuration options for Client, defaulting to values in Default

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Class Method Details

.keysArray

List of configurable keys for Client

Returns:

  • (Array)

    of option keys

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 76

def keys
  @keys ||= %i[
    access_token
    api_endpoint
    auto_paginate
    bearer_token
    client_id
    client_secret
    connection_options
    default_media_type
    login
    management_console_endpoint
    management_console_password
    manage_ghes_endpoint
    manage_ghes_username
    manage_ghes_password
    middleware
    netrc
    netrc_file
    per_page
    password
    proxy
    ssl_verify_mode
    user_agent
    web_endpoint
  ]
end

Instance Attribute Details

#access_token (rw)

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#api_endpointString (rw)

Returns:

[ GitHub ]

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

def api_endpoint
  File.join(@api_endpoint, '')
end

#api_endpoint=(value) ⇒ String (rw)

Returns:

[ GitHub ]

#auto_paginateBoolean (rw)

Returns:

  • (Boolean)

    Auto fetch next page of results until rate limit reached

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#bearer_token (rw)

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#client_idString (rw)

Returns:

  • (String)

    Configure OAuth app key

See Also:

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#client_secret (rw)

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#connection_optionsHash (rw)

Returns:

  • (Hash)

    Configure connection options for Faraday

See Also:

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#default_media_typeString (rw)

Returns:

  • (String)

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

See Also:

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#loginString (rw)

Returns:

  • (String)

    GitHub username for Basic Authentication

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 152

def 
  @login ||= (user. if token_authenticated?)
end

#login=(value) ⇒ String (rw)

Returns:

  • (String)

    GitHub username for Basic Authentication

[ GitHub ]

#manage_ghes_endpointString (rw)

Returns:

  • (String)

    Base URL for API requests to the GitHub Enterprise Server Manage API

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 141

def manage_ghes_endpoint
  File.join(@manage_ghes_endpoint, '')
end

#manage_ghes_endpoint=(value) ⇒ String (rw)

Returns:

  • (String)

    Base URL for API requests to the GitHub Enterprise Server Manage API

[ GitHub ]

#manage_ghes_passwordString (rw)

Returns:

  • (String)

    API user password for requests to the GitHub Enterprise Server Manage API

[ GitHub ]

#manage_ghes_password=(value) ⇒ String (rw)

Returns:

  • (String)

    API user password for requests to the GitHub Enterprise Server Manage API

[ GitHub ]

#manage_ghes_usernameString (rw)

Returns:

  • (String)

    API username for requests to the GitHub Enterprise Server Manage API

[ GitHub ]

#manage_ghes_username=(value) ⇒ String (rw)

Returns:

  • (String)

    API username for requests to the GitHub Enterprise Server Manage API

[ GitHub ]

#management_console_endpointString (rw)

Returns:

  • (String)

    Base URL for API requests to the GitHub Enterprise management console

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 137

def management_console_endpoint
  File.join(@management_console_endpoint, '')
end

#management_console_endpoint=(value) ⇒ String (rw)

Returns:

  • (String)

    Base URL for API requests to the GitHub Enterprise management console

[ GitHub ]

#management_console_passwordString (rw)

Returns:

  • (String)

    An admin password set up for your GitHub Enterprise management console

[ GitHub ]

#management_console_password=(value) ⇒ String (rw)

Returns:

  • (String)

    An admin password set up for your GitHub Enterprise management console

[ GitHub ]

#middlewareFaraday::Builder or Faraday::RackBuilder (rw)

Returns:

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

    Configure middleware for Faraday

See Also:

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#netrcBoolean (rw)

Returns:

  • (Boolean)

    Instruct Octokit to get credentials from .netrc file

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#netrc?Boolean (rw)

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 156

def netrc?
  !!@netrc
end

#netrc_fileString (rw)

Returns:

  • (String)

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

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#password=(value) ⇒ String (writeonly)

Returns:

  • (String)

    GitHub password for Basic Authentication

[ GitHub ]

#per_pageString (rw)

Returns:

  • (String)

    Configure page size for paginated results. API default: 30

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#proxyString (rw)

Returns:

  • (String)

    URI for proxy server

See Also:

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#ssl_verify_modeString (rw)

Returns:

  • (String)

    SSL verify mode for ssl connections

See Also:

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#user_agentString (rw)

Returns:

  • (String)

    Configure User-Agent header for requests.

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 63

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

#web_endpointString (rw)

Base URL for generated web URLs

Returns:

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 148

def web_endpoint
  File.join(@web_endpoint, '')
end

#web_endpoint=(value) ⇒ String (rw)

Returns:

[ GitHub ]

Instance Method Details

#configure {|_self| ... }

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:

  • _self (Configurable)

    the object that the method was called on

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 106

def configure
  yield self
end

#fetch_client_id_and_secret(overrides = {}) (private)

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 166

def fetch_client_id_and_secret(overrides = {})
  opts = options.merge(overrides)
  opts.values_at :client_id, :client_secret
end

#options (private)

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 162

def options
  Octokit::Configurable.keys.to_h { |key| [key, instance_variable_get(:"@#{key}")] }
end

#reset! Also known as: #setup

Reset configuration options to default values

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 111

def reset!
  # rubocop:disable Style/HashEachMethods
  #
  # This may look like a `.keys.each` which should be replaced with `#each_key`, but
  # this doesn't actually work, since `#keys` is just a method we've defined ourselves.
  # The class doesn't fulfill the whole `Enumerable` contract.
  Octokit::Configurable.keys.each do |key|
    # rubocop:enable Style/HashEachMethods
    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

[ GitHub ]

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

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

#setup

Alias for #reset!.

[ GitHub ]

  
# File 'lib/octokit/configurable.rb', line 123

alias setup reset!