Module: Rundeck::Configuration
- Included in:
- Rundeck
- Defined in:
- lib/rundeck/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 Rundeck::API.
[:endpoint, :api_token, :user_agent].freeze
- DEFAULT_USER_AGENT =
The user agent that will be sent to the API endpoint if none is set.
"Rundeck Ruby Gem #{Rundeck::VERSION}".freeze
Class Method Summary collapse
-
.extended(base) ⇒ Object
Sets all configuration options to their default values when this module is extended.
Instance Method Summary collapse
- #api_version ⇒ Object
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
- #endpoint=(endpoint) ⇒ Object
-
#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.
15 16 17 |
# File 'lib/rundeck/configuration.rb', line 15 def self.extended(base) base.reset end |
Instance Method Details
#api_version ⇒ Object
31 32 33 |
# File 'lib/rundeck/configuration.rb', line 31 def api_version '12' end |
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
20 21 22 |
# File 'lib/rundeck/configuration.rb', line 20 def configure yield self end |
#endpoint=(endpoint) ⇒ Object
35 36 37 |
# File 'lib/rundeck/configuration.rb', line 35 def endpoint=(endpoint) @endpoint = "#{endpoint}/api/#{api_version}" end |
#options ⇒ Object
Creates a hash of options and their values.
25 26 27 28 29 |
# File 'lib/rundeck/configuration.rb', line 25 def VALID_OPTIONS_KEYS.reduce({}) do |option, key| option.merge!(key => send(key)) end end |
#reset ⇒ Object
Resets all configuration options to the defaults.
40 41 42 43 44 |
# File 'lib/rundeck/configuration.rb', line 40 def reset self.endpoint = ENV['RUNDECK_ENDPOINT'] self.api_token = ENV['RUNDECK_API_TOKEN'] self.user_agent = DEFAULT_USER_AGENT end |