Module: Gitlab::Configuration

Included in:
Gitlab
Defined in:
lib/gitlab/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
%i[endpoint private_token user_agent sudo httparty pat_prefix body_as_json].freeze
DEFAULT_USER_AGENT =
"Gitlab Ruby Gem #{Gitlab::VERSION}"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



12
13
14
# File 'lib/gitlab/configuration.rb', line 12

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



16
17
18
# File 'lib/gitlab/configuration.rb', line 16

def configure
  yield self
end

#options ⇒ Object



20
21
22
23
24
# File 'lib/gitlab/configuration.rb', line 20

def options
  VALID_OPTIONS_KEYS.each_with_object({}) do |key, option|
    option[key] = send(key)
  end
end

#reset ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/gitlab/configuration.rb', line 26

def reset
  self.endpoint       = ENV['GITLAB_API_ENDPOINT'] || ENV.fetch('CI_API_V4_URL', nil)
  self.private_token  = ENV['GITLAB_API_PRIVATE_TOKEN'] || ENV.fetch('GITLAB_API_AUTH_TOKEN', nil)
  self.pat_prefix     = nil
  self.httparty       = nil
  self.sudo           = nil
  self.user_agent     = DEFAULT_USER_AGENT
  self.body_as_json   = false
end