Class: QAT::Configuration
- Inherits:
-
Object
- Object
- QAT::Configuration
- Extended by:
- Forwardable
- Includes:
- Environment, Parser, Logger, Utils::Network
- Defined in:
- lib/qat/configuration.rb,
lib/qat/configuration/parser.rb,
lib/qat/configuration/environment.rb
Overview
This class represents QAT‘s Configuration manager
This class should be used to manage configurations from multiple environments in test projects. Given a defined environment, all configurations for that environment will be loaded into a cache from the corresponding folder (with the same name) under the config
directory.
A common
folder is also supported which contains configurations shared between multiple environments. A configuration file can exist in both the environment folder and the common folder with the content of both being merged at load time and the configuration from the environment taking precedence over the shared (common) configuration.
Also supported is the cross-referencing of configurations between files. Given a file ‘foo.yml’ with a configuration ‘foo: bar’ and a second file ‘baz.yml’ with configuration ‘baz: foo.foo’, after configurations are loaded to cache, the value of ‘baz’ in cache will be ‘bar’. Cross-referencing between files is made with syntax:
-
<file.yml>
` key: <other_file.yml>.<key> `
Defined Under Namespace
Modules: Environment, Parser Classes: InvalidFolderName, NoEnvironmentDefined, NoEnvironmentFolder
Instance Attribute Summary
Attributes included from Environment
Instance Method Summary collapse
-
#[](key) ⇒ Object
Returns a copy from cache to avoid data manipulation on runtime.
- #directory ⇒ Object
-
#initialize(directory = Dir.pwd, environment = nil) ⇒ Configuration
constructor
A new instance of Configuration.
Methods included from Environment
#each_environment, #environments
Methods included from Utils::Network
Constructor Details
#initialize(directory = Dir.pwd, environment = nil) ⇒ Configuration
Returns a new instance of Configuration.
53 54 55 56 57 58 |
# File 'lib/qat/configuration.rb', line 53 def initialize(directory=Dir.pwd, environment=nil) self.directory = directory log.info { "Initializing configuration from directory #{self.directory}" } self.environment = validate_environment(environment) log.info { "Initialized configuration with environment '#{self.environment}'" } end |
Instance Method Details
#[](key) ⇒ Object
Returns a copy from cache to avoid data manipulation on runtime
63 64 65 |
# File 'lib/qat/configuration.rb', line 63 def [](key) @cache[key].deep_dup end |
#directory ⇒ Object
67 68 69 |
# File 'lib/qat/configuration.rb', line 67 def directory super end |