lib/config_builder/model/root.rb in vagrant-config_builder-0.15.1 vs lib/config_builder/model/root.rb in vagrant-config_builder-1.0.0.rc1

- old
+ new

@@ -1,14 +1,12 @@ # Model the root level Vagrant config object # # @see http://docs.vagrantup.com/v2/vagrantfile/index.html class ConfigBuilder::Model::Root < ConfigBuilder::Model::Base - - include ConfigBuilder::ModelDelegator - def_model_delegator :vagrant def_model_delegator :vms + def_model_delegator :vm_defaults # @!attribute [rw] ssh # @return [Hash<Symbol, Object>] The ssh configuration for all VMs # @example # >> config.ssh @@ -16,10 +14,20 @@ # :username => 'administrator', # :password => 'vagrant', # } def_model_delegator :ssh + # @!attribute [rw] nfs + # @return [Hash<Symbol, Object>] The nfs configuration for all VMs + # @example + # >> config.nfs + # => { + # :nfs_export => true, + # :nfs_version => 4 + # } + def_model_delegator :nfs + # @!attribute [rw] winrm # @return [Hash<Symbol, Object>] The winrm configuration for all VMs # @example # >> config.winrm # => { @@ -38,19 +46,35 @@ end end private + def eval_vm_defaults(root_config) + with_attr(:vm_defaults) do |hash| + v = ConfigBuilder::Model::VM.new_from_hash(hash) + v.call(root_config) + end + end + def eval_vms(root_config) attr(:vms).each do |hash| v = ConfigBuilder::Model::VM.new_from_hash(hash) - v.call(root_config) + root_config.vm.define(v.instance_id, v.instance_options) do |vm_config| + v.call(vm_config) + end end end def eval_vagrant(root_config) if attr(:vagrant).has_key? :host root_config.vagrant.host = attr(:vagrant)[:host] + end + end + + def eval_nfs(root_config) + with_attr(:nfs) do |nfs_config| + f = ConfigBuilder::Model::NFS.new_from_hash(nfs_config) + f.call(root_config) end end def eval_ssh(root_config) with_attr(:ssh) do |ssh_config|