From af32d1f8ca1faac3106feb58a621569b6feea6c6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 11 Jan 2011 12:17:12 -0800 Subject: [PATCH] Pull VM config child classes into their own files --- lib/vagrant/config/vm.rb | 24 +++++++++++------------- lib/vagrant/config/vm/sub_vm.rb | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 lib/vagrant/config/vm/sub_vm.rb diff --git a/lib/vagrant/config/vm.rb b/lib/vagrant/config/vm.rb index 8a4b9e249..4b9d5174b 100644 --- a/lib/vagrant/config/vm.rb +++ b/lib/vagrant/config/vm.rb @@ -1,3 +1,5 @@ +require 'vagrant/config/vm/sub_vm' + module Vagrant class Config class VMConfig < Base @@ -21,16 +23,6 @@ module Vagrant attr_writer :shared_folder_gid attr_accessor :system - # Represents a SubVM. This class is only used here in the VMs - # hash. - class SubVM - include Util::StackedProcRunner - - def options - @options ||= {} - end - end - def initialize @forwarded_ports = {} @shared_folders = {} @@ -95,11 +87,17 @@ module Vagrant end def define(name, options=nil, &block) + name = name.to_sym options ||= {} + + # Add the name to the array of VM keys. This array is used to + # preserve the order in which VMs are defined. defined_vm_keys << name - defined_vms[name.to_sym] ||= SubVM.new - defined_vms[name.to_sym].options.merge!(options) - defined_vms[name.to_sym].push_proc(&block) + + # Add the SubVM to the hash of defined VMs + defined_vms[name] ||= SubVM.new + defined_vms[name].options.merge!(options) + defined_vms[name].push_proc(&block) end def validate(errors) diff --git a/lib/vagrant/config/vm/sub_vm.rb b/lib/vagrant/config/vm/sub_vm.rb new file mode 100644 index 000000000..413a6986e --- /dev/null +++ b/lib/vagrant/config/vm/sub_vm.rb @@ -0,0 +1,17 @@ +module Vagrant + class Config + class VMConfig < Base + # Represents a single sub-VM in a multi-VM environment. + class SubVM + include Util::StackedProcRunner + + attr_reader :options + + def initialize + @options = {} + end + end + end + end +end +