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.
Instance Method Summary collapse
-
#busser_data_for(suite, platform) ⇒ Hash
Generate a new Hash of configuration data that can be used to construct a new Busser object.
-
#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.
-
#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.
Constructor Details
#initialize(data, kitchen_config = {}) ⇒ DataMunger
Constructs a new DataMunger object.
41 42 43 44 45 46 47 48 |
# File 'lib/kitchen/data_munger.rb', line 41 def initialize(data, kitchen_config = {}) @data = data @kitchen_config = kitchen_config convert_legacy_driver_format! convert_legacy_chef_paths_format! convert_legacy_require_chef_omnibus_format! move_chef_data_to_provisioner! end |
Instance Method Details
#busser_data_for(suite, platform) ⇒ Hash
Generate a new Hash of configuration data that can be used to construct a new Busser object.
57 58 59 60 61 62 63 |
# File 'lib/kitchen/data_munger.rb', line 57 def busser_data_for(suite, platform) merged_data_for(:busser, suite, platform, :version).tap do |bdata| set_kitchen_config_at!(bdata, :kitchen_root) set_kitchen_config_at!(bdata, :test_base_path) set_kitchen_config_at!(bdata, :log_level) end end |
#driver_data_for(suite, platform) ⇒ Hash
Generate a new Hash of configuration data that can be used to construct a new Driver object.
72 73 74 75 76 77 78 |
# File 'lib/kitchen/data_munger.rb', line 72 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 |
#platform_data ⇒ Array<Hash>
Returns an Array of platform Hashes.
83 84 85 |
# File 'lib/kitchen/data_munger.rb', line 83 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.
94 95 96 97 98 99 100 101 |
# File 'lib/kitchen/data_munger.rb', line 94 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, :log_level) combine_arrays!(pdata, :run_list, :platform, :suite) end end |
#suite_data ⇒ Array<Hash>
Returns an Array of suite Hashes.
106 107 108 |
# File 'lib/kitchen/data_munger.rb', line 106 def suite_data data.fetch(:suites, []) end |