Class: R10K::Deployment::Config Private
- Inherits:
-
Object
- Object
- R10K::Deployment::Config
- Includes:
- Logging
- Defined in:
- lib/r10k/deployment/config.rb,
lib/r10k/deployment/config/loader.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: ConfigError, Loader
Constant Summary
Constants included from Logging
Instance Attribute Summary collapse
- #configfile ⇒ Object private
Instance Method Summary collapse
-
#initialize(configfile) ⇒ Config
constructor
private
A new instance of Config.
-
#load_config ⇒ Object
private
Load and store a config file, and set relevant options.
-
#setting(key) ⇒ Object
private
Perform a scan for key and check for both string and symbol keys.
Methods included from Logging
debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level
Constructor Details
#initialize(configfile) ⇒ Config
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Config.
15 16 17 18 19 |
# File 'lib/r10k/deployment/config.rb', line 15 def initialize(configfile) @configfile = configfile load_config end |
Instance Attribute Details
#configfile ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/r10k/deployment/config.rb', line 13 def configfile @configfile end |
Instance Method Details
#load_config ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Load and store a config file, and set relevant options
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/r10k/deployment/config.rb', line 41 def load_config if @configfile.nil? loader = R10K::Deployment::Config::Loader.new @configfile = loader.search if @configfile.nil? raise ConfigError, "No configuration file given, no config file found in current directory, and no global config present" end end begin @config = ::YAML.load_file(@configfile) apply_config_settings rescue => e raise ConfigError, "Couldn't load config file: #{e.}" end end |
#setting(key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Perform a scan for key and check for both string and symbol keys
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/r10k/deployment/config.rb', line 22 def setting(key) keys = [key] case key when String keys << key.to_sym when Symbol keys << key.to_s end # Scan all possible keys to see if the config has a matching value keys.inject(nil) do |rv, k| v = @config[k] break v unless v.nil? end end |