Module: Sonarqube::Configuration
- Included in:
- Sonarqube
- Defined in:
- lib/sonarqube/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 Sonarqube::API.
%i[endpoint private_token user_agent httparty].freeze
- DEFAULT_USER_AGENT =
The user agent that will be sent to the API endpoint if none is set.
"Sonarqube Ruby Gem #{Sonarqube::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
permalink .extended(base) ⇒ Object
Sets all configuration options to their default values when this module is extended.
19 20 21 |
# File 'lib/sonarqube/configuration.rb', line 19 def self.extended(base) base.reset end |
Instance Method Details
permalink #configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
24 25 26 |
# File 'lib/sonarqube/configuration.rb', line 24 def configure yield self end |
permalink #options ⇒ Object
Creates a hash of options and their values.
29 30 31 32 33 |
# File 'lib/sonarqube/configuration.rb', line 29 def VALID_OPTIONS_KEYS.inject({}) do |option, key| option.merge!(key => send(key)) end end |
permalink #reset ⇒ Object
Resets all configuration options to the defaults.
36 37 38 39 40 41 |
# File 'lib/sonarqube/configuration.rb', line 36 def reset self.endpoint = ENV['SONARQUBE_API_ENDPOINT'] self.private_token = ENV['SONARQUBE_API_PRIVATE_TOKEN'] self.httparty = get_httparty_config(ENV['SONARQUBE_API_HTTPARTY_OPTIONS']) self.user_agent = DEFAULT_USER_AGENT end |