Class: Kitchen::Loader::YAML
- Inherits:
-
Object
- Object
- Kitchen::Loader::YAML
- Defined in:
- lib/kitchen/loader/yaml.rb
Overview
YAML file loader for Test Kitchen configuration. This class is responisble for parsing the main YAML file and the local YAML if it exists. Local file configuration will win over the default configuration. The client of this class should not require any YAML loading or parsing logic.
Instance Method Summary collapse
-
#diagnose ⇒ Hash
Returns a Hash of configuration and other useful diagnostic information.
-
#initialize(options = {}) ⇒ YAML
constructor
Creates a new loader that can parse and load YAML files.
-
#read ⇒ Hash
Reads, parses, and merges YAML configuration files and returns a Hash of tne merged data.
Constructor Details
#initialize(options = {}) ⇒ YAML
Creates a new loader that can parse and load YAML files.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/kitchen/loader/yaml.rb', line 46 def initialize( = {}) @config_file = File.([:project_config] || default_config_file) @local_config_file = File.([:local_config] || default_local_config_file) @global_config_file = File.([:global_config] || default_global_config_file) @process_erb = .fetch(:process_erb, true) @process_local = .fetch(:process_local, true) @process_global = .fetch(:process_global, true) end |
Instance Method Details
#diagnose ⇒ Hash
Returns a Hash of configuration and other useful diagnostic information.
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/kitchen/loader/yaml.rb', line 74 def diagnose result = {} result[:process_erb] = @process_erb result[:process_local] = @process_local result[:process_global] = @process_global result[:global_config] = diagnose_component(:global_yaml, global_config_file) result[:project_config] = diagnose_component(:yaml, config_file) result[:local_config] = diagnose_component(:local_yaml, local_config_file) result[:combined_config] = diagnose_component(:combined_hash) result end |
#read ⇒ Hash
Reads, parses, and merges YAML configuration files and returns a Hash of tne merged data.
63 64 65 66 67 68 69 |
# File 'lib/kitchen/loader/yaml.rb', line 63 def read unless File.exist?(config_file) raise UserError, "Kitchen YAML file #{config_file} does not exist." end Util.symbolized_hash(combined_hash) end |