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.



57
58
59
# File 'lib/octokit/configurable.rb', line 57

def access_token
  @access_token
end

#api_endpointString



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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

#auto_paginateBoolean



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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_tokenObject

Returns the value of attribute bearer_token.



57
58
59
# File 'lib/octokit/configurable.rb', line 57

def bearer_token
  @bearer_token
end

#client_idString

Returns Configure OAuth app key.



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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_secretObject

Returns the value of attribute client_secret.



57
58
59
# File 'lib/octokit/configurable.rb', line 57

def client_secret
  @client_secret
end

#connection_optionsHash

Returns Configure connection options for Faraday.



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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

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



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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

#management_console_endpointString



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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

#management_console_passwordString



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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

#middlewareFaraday::Builder or Faraday::RackBuilder

Returns Configure middleware for Faraday.



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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_fileString



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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)



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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

#per_pageString



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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

Returns URI for proxy server.



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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

Returns SSL verify mode for ssl connections.



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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

Base URL for generated web URLs



57
58
59
60
# File 'lib/octokit/configurable.rb', line 57

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

Class Method Details

.keysArray

List of configurable keys for Octokit::Client



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

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

Instance Method Details

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

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:



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

def configure
  yield self
end

#netrc?Boolean



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

def netrc?
  !!@netrc
end

#reset!Object Also known as: setup

Reset configuration options to default values



99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/octokit/configurable.rb', line 99

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



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

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