Class: Kitchen::DataMunger
- Inherits:
-
Object
- Object
- Kitchen::DataMunger
- Defined in:
- lib/kitchen/data_munger.rb
Overview
Class to handle recursive merging of configuration between platforms, suites, and common data.
This object will mutate the data Hash passed into its constructor and so should not be reused or shared across threads.
If you are squeamish or faint of heart, then you might want to skip this class. Just remember, you were warned. And if you made it this far, be sure to tweet at @fnichol and let him know your fear factor level.
Defined Under Namespace
Classes: LegacyConfigNormalizer, MergeResolver
Instance Method Summary collapse
-
#driver_data_for(suite, platform) ⇒ Hash
Generate a new Hash of configuration data that can be used to construct a new Driver object.
-
#initialize(data, kitchen_config = {}) ⇒ DataMunger
constructor
Constructs a new DataMunger object.
-
#lifecycle_hooks_data_for(suite, platform) ⇒ Hash
Generate a new Hash of configuration data that can be used to construct a new LifecycleHooks object.
-
#platform_data ⇒ Array<Hash>
Returns an Array of platform Hashes.
-
#provisioner_data_for(suite, platform) ⇒ Hash
Generate a new Hash of configuration data that can be used to construct a new Provisioner object.
-
#suite_data ⇒ Array<Hash>
Returns an Array of suite Hashes.
-
#transport_data_for(suite, platform) ⇒ Hash
Generate a new Hash of configuration data that can be used to construct a new Transport object.
-
#verifier_data_for(suite, platform) ⇒ Hash
Generate a new Hash of configuration data that can be used to construct a new Verifier object.
Constructor Details
#initialize(data, kitchen_config = {}) ⇒ DataMunger
Constructs a new DataMunger object.
38 39 40 41 42 |
# File 'lib/kitchen/data_munger.rb', line 38 def initialize(data, kitchen_config = {}) @data = data @kitchen_config = kitchen_config LegacyConfigNormalizer.new(self).normalize! end |
Instance Method Details
#driver_data_for(suite, platform) ⇒ Hash
Generate a new Hash of configuration data that can be used to construct a new Driver object.
51 52 53 54 55 56 57 |
# File 'lib/kitchen/data_munger.rb', line 51 def driver_data_for(suite, platform) merged_data_for(:driver, suite, platform).tap do |ddata| set_kitchen_config_at!(ddata, :kitchen_root) set_kitchen_config_at!(ddata, :test_base_path) set_kitchen_config_at!(ddata, :log_level) end end |
#lifecycle_hooks_data_for(suite, platform) ⇒ Hash
Generate a new Hash of configuration data that can be used to construct a new LifecycleHooks object.
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/kitchen/data_munger.rb', line 66 def lifecycle_hooks_data_for(suite, platform) merged_data_for(:lifecycle, suite, platform).tap do |lhdata| lhdata.each_key do |k| combine_arrays!(lhdata, k, :common, :platform, :suite) end set_kitchen_config_at!(lhdata, :kitchen_root) set_kitchen_config_at!(lhdata, :test_base_path) set_kitchen_config_at!(lhdata, :log_level) set_kitchen_config_at!(lhdata, :debug) end end |
#platform_data ⇒ Array<Hash>
Returns an Array of platform Hashes.
81 82 83 |
# File 'lib/kitchen/data_munger.rb', line 81 def platform_data data.fetch(:platforms, []) end |
#provisioner_data_for(suite, platform) ⇒ Hash
Generate a new Hash of configuration data that can be used to construct a new Provisioner object.
92 93 94 95 96 97 98 99 |
# File 'lib/kitchen/data_munger.rb', line 92 def provisioner_data_for(suite, platform) merged_data_for(:provisioner, suite, platform).tap do |pdata| set_kitchen_config_at!(pdata, :kitchen_root) set_kitchen_config_at!(pdata, :test_base_path) set_kitchen_config_at!(pdata, :debug) combine_arrays!(pdata, :run_list, :platform, :suite) end end |
#suite_data ⇒ Array<Hash>
Returns an Array of suite Hashes.
104 105 106 |
# File 'lib/kitchen/data_munger.rb', line 104 def suite_data data.fetch(:suites, []) end |
#transport_data_for(suite, platform) ⇒ Hash
Generate a new Hash of configuration data that can be used to construct a new Transport object.
115 116 117 118 119 120 121 |
# File 'lib/kitchen/data_munger.rb', line 115 def transport_data_for(suite, platform) merged_data_for(:transport, suite, platform).tap do |tdata| set_kitchen_config_at!(tdata, :kitchen_root) set_kitchen_config_at!(tdata, :test_base_path) set_kitchen_config_at!(tdata, :log_level) end end |
#verifier_data_for(suite, platform) ⇒ Hash
Generate a new Hash of configuration data that can be used to construct a new Verifier object.
130 131 132 133 134 135 136 137 |
# File 'lib/kitchen/data_munger.rb', line 130 def verifier_data_for(suite, platform) merged_data_for(:verifier, suite, platform).tap do |vdata| set_kitchen_config_at!(vdata, :kitchen_root) set_kitchen_config_at!(vdata, :test_base_path) set_kitchen_config_at!(vdata, :log_level) set_kitchen_config_at!(vdata, :debug) end end |