lib/vagrant/env.rb in vagrantup-0.1.1 vs lib/vagrant/env.rb in vagrantup-0.1.2

- old
+ new

@@ -17,12 +17,12 @@ def dotfile_path;File.join(root_path, Vagrant.config.vagrant.dotfile_name); end def home_path; File.expand_path(Vagrant.config.vagrant.home); end def tmp_path; File.join(home_path, "tmp"); end def boxes_path; File.join(home_path, "boxes"); end - def load!(opts={}) - load_root_path!(Pathname.new(Dir.pwd), opts) + def load! + load_root_path! load_config! load_home_directory! load_box! load_vm! end @@ -58,20 +58,22 @@ FileUtils.mkdir_p(dir) end end def load_box! + return unless root_path + @@box = Box.find(Vagrant.config.vm.box) if Vagrant.config.vm.box if @@box logger.info("Reloading configuration to account for loaded box...") load_config! end end def load_vm! - return unless root_path + return if !root_path || !File.file?(dotfile_path) File.open(dotfile_path) do |f| @@persisted_vm = Vagrant::VM.find(f.read) end rescue Errno::ENOENT @@ -82,32 +84,38 @@ File.open(dotfile_path, 'w+') do |f| f.write(vm.uuid) end end - def load_root_path!(path=Pathname.new(Dir.pwd), opts={}) - if path.to_s == '/' - return false if opts[:suppress_errors] - error_and_exit(<<-msg) -A `#{ROOTFILE_NAME}` was not found! This file is required for vagrant to run -since it describes the expected environment that vagrant is supposed -to manage. Please create a #{ROOTFILE_NAME} and place it in your project -root. -msg - return - end + def load_root_path!(path=nil) + path ||= Pathname.new(Dir.pwd) + return false if path.to_s == '/' + file = "#{path}/#{ROOTFILE_NAME}" if File.exist?(file) @@root_path = path.to_s return true end - load_root_path!(path.parent, opts) + load_root_path!(path.parent) end + def require_root_path + if !root_path + error_and_exit(<<-msg) +A `#{ROOTFILE_NAME}` was not found! This file is required for vagrant to run +since it describes the expected environment that vagrant is supposed +to manage. Please create a #{ROOTFILE_NAME} and place it in your project +root. +msg + end + end + def require_box + require_root_path + if !box if !Vagrant.config.vm.box error_and_exit(<<-msg) No base box was specified! A base box is required as a staring point for every vagrant virtual machine. Please specify one in your Vagrantfile @@ -123,9 +131,11 @@ end end end def require_persisted_vm + require_root_path + if !persisted_vm error_and_exit(<<-error) The task you're trying to run requires that the vagrant environment already be created, but unfortunately this vagrant still appears to have no box! You can setup the environment by setting up your