Module: Gitlab::Configuration
- Included in:
- Gitlab
- Defined in:
- lib/gitlab/configuration.rb
Overview
Defines constants and methods related to configuration.
Constant Summary collapse
- VALID_OPTIONS_KEYS =
An array of valid keys in the options hash when configuring a Gitlab::API.
%i[endpoint private_token user_agent sudo httparty pat_prefix].freeze
- DEFAULT_USER_AGENT =
The user agent that will be sent to the API endpoint if none is set.
"Gitlab Ruby Gem #{Gitlab::VERSION}"
Class Method Summary collapse
-
.extended(base) ⇒ Object
Sets all configuration options to their default values when this module is extended.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
-
#options ⇒ Object
Creates a hash of options and their values.
-
#reset ⇒ Object
Resets all configuration options to the defaults.
Class Method Details
.extended(base) ⇒ Object
Sets all configuration options to their default values when this module is extended.
20 21 22 |
# File 'lib/gitlab/configuration.rb', line 20 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
25 26 27 |
# File 'lib/gitlab/configuration.rb', line 25 def configure yield self end |
#options ⇒ Object
Creates a hash of options and their values.
30 31 32 33 34 |
# File 'lib/gitlab/configuration.rb', line 30 def VALID_OPTIONS_KEYS.inject({}) do |option, key| option.merge!(key => send(key)) end end |
#reset ⇒ Object
Resets all configuration options to the defaults.
37 38 39 40 41 42 43 44 |
# File 'lib/gitlab/configuration.rb', line 37 def reset self.endpoint = ENV['GITLAB_API_ENDPOINT'] || ENV['CI_API_V4_URL'] self.private_token = ENV['GITLAB_API_PRIVATE_TOKEN'] || ENV['GITLAB_API_AUTH_TOKEN'] self.pat_prefix = nil self.httparty = get_httparty_config(ENV['GITLAB_API_HTTPARTY_OPTIONS']) self.sudo = nil self.user_agent = DEFAULT_USER_AGENT end |