From 4844d6c12f6973938130501d7a155a6be6b503b1 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 23 Aug 2010 21:41:40 -0700 Subject: [PATCH] Moved standard library requirements to the files which use them. Cleaned up vagrant.rb quite a bit. --- lib/vagrant.rb | 14 +++++--------- lib/vagrant/action/box/destroy.rb | 2 ++ lib/vagrant/action/box/unpackage.rb | 3 +++ lib/vagrant/action/general/package.rb | 3 +++ lib/vagrant/action/vm/export.rb | 2 ++ lib/vagrant/downloaders/file.rb | 2 ++ lib/vagrant/environment.rb | 3 +++ lib/vagrant/provisioners/chef_server.rb | 2 ++ lib/vagrant/ssh.rb | 4 ++++ lib/vagrant/util/plain_logger.rb | 2 ++ lib/vagrant/util/platform.rb | 2 ++ lib/vagrant/util/resource_logger.rb | 1 + 12 files changed, 31 insertions(+), 9 deletions(-) diff --git a/lib/vagrant.rb b/lib/vagrant.rb index be0d4e465..28ce5a741 100644 --- a/lib/vagrant.rb +++ b/lib/vagrant.rb @@ -1,8 +1,6 @@ -# First, load the various libs which Vagrant requires -%w{tempfile json pathname logger virtualbox net/ssh archive/tar/minitar - net/scp fileutils mario}.each do |lib| - require lib -end +require 'json' +require 'virtualbox' +require "vagrant/util/glob_loader" module Vagrant class << self @@ -14,10 +12,8 @@ module Vagrant end end -# Then load the glob loader, which will handle loading everything else -require "vagrant/util/glob_loader" - -# Load them up +# Load them up. One day we'll convert this to autoloads. Today +# is not that day. Low hanging fruit for anyone wishing to do it. libdir = File.expand_path("lib/vagrant", Vagrant.source_root) Vagrant::GlobLoader.glob_require(libdir, %w{util util/stacked_proc_runner downloaders/base config provisioners/base provisioners/chef systems/base diff --git a/lib/vagrant/action/box/destroy.rb b/lib/vagrant/action/box/destroy.rb index 36cdacafd..28d36458f 100644 --- a/lib/vagrant/action/box/destroy.rb +++ b/lib/vagrant/action/box/destroy.rb @@ -1,3 +1,5 @@ +require 'fileutils' + module Vagrant class Action module Box diff --git a/lib/vagrant/action/box/unpackage.rb b/lib/vagrant/action/box/unpackage.rb index 79f832ab5..87899daec 100644 --- a/lib/vagrant/action/box/unpackage.rb +++ b/lib/vagrant/action/box/unpackage.rb @@ -1,3 +1,6 @@ +require 'fileutils' +require 'archive/tar/minitar' + module Vagrant class Action module Box diff --git a/lib/vagrant/action/general/package.rb b/lib/vagrant/action/general/package.rb index 40bbe9de8..a16f9ffb4 100644 --- a/lib/vagrant/action/general/package.rb +++ b/lib/vagrant/action/general/package.rb @@ -1,3 +1,6 @@ +require 'fileutils' +require 'archive/tar/minitar' + module Vagrant class Action module General diff --git a/lib/vagrant/action/vm/export.rb b/lib/vagrant/action/vm/export.rb index e4c7e0909..0c69ed52f 100644 --- a/lib/vagrant/action/vm/export.rb +++ b/lib/vagrant/action/vm/export.rb @@ -1,3 +1,5 @@ +require 'fileutils' + module Vagrant class Action module VM diff --git a/lib/vagrant/downloaders/file.rb b/lib/vagrant/downloaders/file.rb index 38ba7bf34..67bfccdca 100644 --- a/lib/vagrant/downloaders/file.rb +++ b/lib/vagrant/downloaders/file.rb @@ -1,3 +1,5 @@ +require 'fileutils' + module Vagrant module Downloaders # "Downloads" a file to a temporary file. Basically, this downloader diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 61f8fc043..96be3f008 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -1,3 +1,6 @@ +require 'pathname' +require 'fileutils' + module Vagrant # Represents a single Vagrant environment. This class is responsible # for loading all of the Vagrantfile's for the given environment and diff --git a/lib/vagrant/provisioners/chef_server.rb b/lib/vagrant/provisioners/chef_server.rb index b4677c0c6..13826950c 100644 --- a/lib/vagrant/provisioners/chef_server.rb +++ b/lib/vagrant/provisioners/chef_server.rb @@ -1,3 +1,5 @@ +require 'pathname' + module Vagrant module Provisioners # This class implements provisioning via chef-client, allowing provisioning diff --git a/lib/vagrant/ssh.rb b/lib/vagrant/ssh.rb index 00072500e..86daffd8a 100644 --- a/lib/vagrant/ssh.rb +++ b/lib/vagrant/ssh.rb @@ -1,3 +1,7 @@ +require 'net/ssh' +require 'net/scp' +require 'mario' + module Vagrant # Manages SSH access to a specific environment. Allows an environment to # replace the process with SSH itself, run a specific set of commands, diff --git a/lib/vagrant/util/plain_logger.rb b/lib/vagrant/util/plain_logger.rb index 262b0c56e..71927ee72 100644 --- a/lib/vagrant/util/plain_logger.rb +++ b/lib/vagrant/util/plain_logger.rb @@ -1,3 +1,5 @@ +require 'logger' + module Vagrant module Util # Subclass of the standard library logger which has no format on diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb index 74f37134d..8be0e4fe6 100644 --- a/lib/vagrant/util/platform.rb +++ b/lib/vagrant/util/platform.rb @@ -1,3 +1,5 @@ +require 'mario' + module Vagrant module Util # This class just contains some platform checking code. diff --git a/lib/vagrant/util/resource_logger.rb b/lib/vagrant/util/resource_logger.rb index 43941d83a..ce9cf700b 100644 --- a/lib/vagrant/util/resource_logger.rb +++ b/lib/vagrant/util/resource_logger.rb @@ -1,4 +1,5 @@ require 'thread' +require 'mario' module Vagrant module Util