Module: BitBucket::Configuration

Included in:
BitBucket
Defined in:
lib/bitbucket_rest_api/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
%i[
  adapter
  client_id
  client_secret
  new_access_token
  oauth_token
  oauth_secret
  endpoint
  mime_type
  user_agent
  connection_options
  repo
  user
  login
  password
  basic_auth
].freeze
DEFAULT_ADAPTER =

Other adapters are :typhoeus, :patron, :em_synchrony, :excon, :test

:net_http
DEFAULT_CLIENT_ID =

By default, don’t set an application key

nil
DEFAULT_CLIENT_SECRET =

By default, don’t set an application secret

nil
DEFAULT_ACCESS_TOKEN =

By default, don’t set an access token

nil
DEFAULT_OAUTH_TOKEN =

By default, don’t set a user oauth access token

nil
DEFAULT_OAUTH_SECRET =

By default, don’t set a user oauth access token secret

nil
DEFAULT_LOGIN =

By default, don’t set a user login name

nil
DEFAULT_PASSWORD =

By default, don’t set a user password

nil
DEFAULT_BASIC_AUTH =

By default, don’t set a user basic authentication

nil
DEFAULT_ENDPOINT =

The endpoint used to connect to BitBucket if none is set, in the event that BitBucket is ever available on location

'https://api.bitbucket.org'
DEFAULT_USER_AGENT =

The value sent in the http header for ‘User-Agent’ if none is set

"BitBucket Ruby Gem #{BitBucket::VERSION::STRING}"
DEFAULT_MIME_TYPE =

By default the Accept header will make a request for JSON

:json
DEFAULT_CONNECTION_OPTIONS =

By default uses the Faraday connection options if none is set

{}.freeze
DEFAULT_USER =

By default, don’t set user name

nil
DEFAULT_REPO =

By default, don’t set repository name

nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



74
75
76
# File 'lib/bitbucket_rest_api/configuration.rb', line 74

def self.extended(base)
  base.set_defaults
end

Instance Method Details

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

Convenience method to allow for global setting of configuration options

Yields:

  • (_self)

Yield Parameters:



70
71
72
# File 'lib/bitbucket_rest_api/configuration.rb', line 70

def configure
  yield self
end

#optionsObject



78
79
80
81
82
# File 'lib/bitbucket_rest_api/configuration.rb', line 78

def options
  options = {}
  VALID_OPTIONS_KEYS.each { |k| options[k] = send(k) }
  options
end

#set_defaultsObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/bitbucket_rest_api/configuration.rb', line 84

def set_defaults
  self.adapter            = DEFAULT_ADAPTER
  self.client_id          = DEFAULT_CLIENT_ID
  self.client_secret      = DEFAULT_CLIENT_SECRET
  self.new_access_token   = DEFAULT_ACCESS_TOKEN
  self.oauth_token        = DEFAULT_OAUTH_TOKEN
  self.oauth_secret       = DEFAULT_OAUTH_SECRET
  self.endpoint           = DEFAULT_ENDPOINT
  self.user_agent         = DEFAULT_USER_AGENT
  self.connection_options = DEFAULT_CONNECTION_OPTIONS
  self.mime_type          = DEFAULT_MIME_TYPE
  self.user               = DEFAULT_USER
  self.repo               = DEFAULT_REPO
  self.              = DEFAULT_LOGIN
  self.password           = DEFAULT_PASSWORD
  self.basic_auth         = DEFAULT_BASIC_AUTH
  self
end