Get rid of autoload use in Guests

I don't use `activated` here because I'd really like to optimize
performance as much as possible, and loading files from disk is
generally slow. So instead of using `activated` I load the file at the
last possible moment which is when the exact class is being requested.

I don't think many people will do this outside of the core, and I'm not
too concerned.
This commit is contained in:
Mitchell Hashimoto 2012-05-23 15:57:43 -07:00
parent d5a7ca6159
commit 459d82689e
21 changed files with 93 additions and 39 deletions

View File

@ -1,8 +1,11 @@
require 'set' require 'set'
require 'tempfile' require 'tempfile'
require "vagrant"
require 'vagrant/util/template_renderer' require 'vagrant/util/template_renderer'
require Vagrant.source_root.join("plugins/guests/linux/guest")
module VagrantPlugins module VagrantPlugins
module GuestArch module GuestArch
class Guest < VagrantPlugins::GuestLinux::Guest class Guest < VagrantPlugins::GuestLinux::Guest

View File

@ -2,13 +2,14 @@ require "vagrant"
module VagrantPlugins module VagrantPlugins
module GuestArch module GuestArch
autoload :Guest, File.expand_path("../guest", __FILE__)
class Plugin < Vagrant.plugin("1") class Plugin < Vagrant.plugin("1")
name "Arch guest" name "Arch guest"
description "Arch guest support." description "Arch guest support."
guest("arch") { Guest } guest("arch") do
require File.expand_path("../guest", __FILE__)
Guest
end
end end
end end
end end

View File

@ -1,8 +1,11 @@
require 'set' require 'set'
require 'tempfile' require 'tempfile'
require "vagrant"
require 'vagrant/util/template_renderer' require 'vagrant/util/template_renderer'
require Vagrant.source_root.join("plugins/guests/linux/guest")
module VagrantPlugins module VagrantPlugins
module GuestDebian module GuestDebian
class Guest < VagrantPlugins::GuestLinux::Guest class Guest < VagrantPlugins::GuestLinux::Guest

View File

@ -2,13 +2,14 @@ require "vagrant"
module VagrantPlugins module VagrantPlugins
module GuestDebian module GuestDebian
autoload :Guest, File.expand_path("../guest", __FILE__)
class Plugin < Vagrant.plugin("1") class Plugin < Vagrant.plugin("1")
name "Debian guest" name "Debian guest"
description "Debian guest support." description "Debian guest support."
guest("debian") { Guest } guest("debian") do
require File.expand_path("../guest", __FILE__)
Guest
end
end end
end end
end end

View File

@ -1,8 +1,11 @@
require 'set' require 'set'
require 'tempfile' require 'tempfile'
require "vagrant"
require 'vagrant/util/template_renderer' require 'vagrant/util/template_renderer'
require Vagrant.source_root.join("plugins/guests/linux/guest")
module VagrantPlugins module VagrantPlugins
module GuestFedora module GuestFedora
class Guest < VagrantPlugins::GuestLinux::Guest class Guest < VagrantPlugins::GuestLinux::Guest

View File

@ -2,13 +2,17 @@ require "vagrant"
module VagrantPlugins module VagrantPlugins
module GuestFedora module GuestFedora
autoload :Guest, File.expand_path("../guest", __FILE__)
class Plugin < Vagrant.plugin("1") class Plugin < Vagrant.plugin("1")
name "Fedora guest" name "Fedora guest"
description "Fedora guest support." description "Fedora guest support."
guest("fedora") { Guest } activated do
end
guest("fedora") do
require File.expand_path("../guest", __FILE__)
Guest
end
end end
end end
end end

View File

@ -2,15 +2,19 @@ require "vagrant"
module VagrantPlugins module VagrantPlugins
module GuestFreeBSD module GuestFreeBSD
autoload :Config, File.expand_path("../config", __FILE__)
autoload :Guest, File.expand_path("../guest", __FILE__)
class Plugin < Vagrant.plugin("1") class Plugin < Vagrant.plugin("1")
name "FreeBSD guest" name "FreeBSD guest"
description "FreeBSD guest support." description "FreeBSD guest support."
config("freebsd") { Config } config("freebsd") do
guest("freebsd") { Guest } require File.expand_path("../config", __FILE__)
Config
end
guest("freebsd") do
require File.expand_path("../guest", __FILE__)
Guest
end
end end
end end
end end

View File

@ -1,7 +1,10 @@
require 'tempfile' require 'tempfile'
require "vagrant"
require 'vagrant/util/template_renderer' require 'vagrant/util/template_renderer'
require Vagrant.source_root.join("plugins/guests/linux/guest")
module VagrantPlugins module VagrantPlugins
module GuestGentoo module GuestGentoo
class Guest < VagrantPlugins::GuestLinux::Guest class Guest < VagrantPlugins::GuestLinux::Guest

View File

@ -2,13 +2,14 @@ require "vagrant"
module VagrantPlugins module VagrantPlugins
module GuestGentoo module GuestGentoo
autoload :Guest, File.expand_path("../guest", __FILE__)
class Plugin < Vagrant.plugin("1") class Plugin < Vagrant.plugin("1")
name "Gentoo guest" name "Gentoo guest"
description "Gentoo guest support." description "Gentoo guest support."
guest("gentoo") { Guest } guest("gentoo") do
require File.expand_path("../guest", __FILE__)
Guest
end
end end
end end
end end

View File

@ -1,5 +1,7 @@
require 'log4r' require 'log4r'
require "vagrant"
module VagrantPlugins module VagrantPlugins
module GuestLinux module GuestLinux
class Guest < Vagrant::Guest::Base class Guest < Vagrant::Guest::Base

View File

@ -2,15 +2,19 @@ require "vagrant"
module VagrantPlugins module VagrantPlugins
module GuestLinux module GuestLinux
autoload :Config, File.expand_path("../config", __FILE__)
autoload :Guest, File.expand_path("../guest", __FILE__)
class Plugin < Vagrant.plugin("1") class Plugin < Vagrant.plugin("1")
name "Linux guest." name "Linux guest."
description "Linux guest support." description "Linux guest support."
config("linux") { Config } config("linux") do
guest("linux") { Guest } require File.expand_path("../config", __FILE__)
Config
end
guest("linux") do
require File.expand_path("../guest", __FILE__)
Guest
end
end end
end end
end end

View File

@ -1,3 +1,7 @@
require "vagrant"
require Vagrant.source_root.join("plugins/guests/linux/guest")
module VagrantPlugins module VagrantPlugins
module GuestOpenBSD module GuestOpenBSD
class Guest < VagrantPlugins::GuestLinux::Guest class Guest < VagrantPlugins::GuestLinux::Guest

View File

@ -2,13 +2,14 @@ require "vagrant"
module VagrantPlugins module VagrantPlugins
module GuestOpenBSD module GuestOpenBSD
autoload :Guest, File.expand_path("../guest", __FILE__)
class Plugin < Vagrant.plugin("1") class Plugin < Vagrant.plugin("1")
name "OpenBSD guest" name "OpenBSD guest"
description "OpenBSD guest support." description "OpenBSD guest support."
guest("openbsd") { Guest } guest("openbsd") do
require File.expand_path("../guest", __FILE__)
Guest
end
end end
end end
end end

View File

@ -1,8 +1,11 @@
require 'set' require 'set'
require 'tempfile' require 'tempfile'
require "vagrant"
require 'vagrant/util/template_renderer' require 'vagrant/util/template_renderer'
require Vagrant.source_root.join("plugins/guests/linux/guest")
module VagrantPlugins module VagrantPlugins
module GuestRedHat module GuestRedHat
class Guest < VagrantPlugins::GuestLinux::Guest class Guest < VagrantPlugins::GuestLinux::Guest

View File

@ -2,13 +2,14 @@ require "vagrant"
module VagrantPlugins module VagrantPlugins
module GuestRedHat module GuestRedHat
autoload :Guest, File.expand_path("../guest", __FILE__)
class Plugin < Vagrant.plugin("1") class Plugin < Vagrant.plugin("1")
name "RedHat guest" name "RedHat guest"
description "RedHat guest support." description "RedHat guest support."
guest("redhat") { Guest } guest("redhat") do
require File.expand_path("../guest", __FILE__)
Guest
end
end end
end end
end end

View File

@ -1,3 +1,5 @@
require "vagrant"
module VagrantPlugins module VagrantPlugins
module GuestSolaris module GuestSolaris
# A general Vagrant system implementation for "solaris". # A general Vagrant system implementation for "solaris".

View File

@ -2,15 +2,19 @@ require "vagrant"
module VagrantPlugins module VagrantPlugins
module GuestSolaris module GuestSolaris
autoload :Config, File.expand_path("../config", __FILE__)
autoload :Guest, File.expand_path("../guest", __FILE__)
class Plugin < Vagrant.plugin("1") class Plugin < Vagrant.plugin("1")
name "Solaris guest." name "Solaris guest."
description "Solaris guest support." description "Solaris guest support."
config("solaris") { Config } config("solaris") do
guest("solaris") { Guest } require File.expand_path("../config", __FILE__)
Config
end
guest("solaris") do
require File.expand_path("../guest", __FILE__)
Guest
end
end end
end end
end end

View File

@ -1,3 +1,7 @@
require "vagrant"
require Vagrant.source_root.join("plugins/guests/redhat/guest")
module VagrantPlugins module VagrantPlugins
module GuestSuse module GuestSuse
class Guest < VagrantPlugins::GuestRedHat::Guest class Guest < VagrantPlugins::GuestRedHat::Guest

View File

@ -2,13 +2,14 @@ require "vagrant"
module VagrantPlugins module VagrantPlugins
module GuestSuse module GuestSuse
autoload :Guest, File.expand_path("../guest", __FILE__)
class Plugin < Vagrant.plugin("1") class Plugin < Vagrant.plugin("1")
name "SUSE guest" name "SUSE guest"
description "SUSE guest support." description "SUSE guest support."
guest("suse") { Guest } guest("suse") do
require File.expand_path("../guest", __FILE__)
Guest
end
end end
end end
end end

View File

@ -1,3 +1,7 @@
require "vagrant"
require Vagrant.source_root.join("plugins/guests/debian/guest")
module VagrantPlugins module VagrantPlugins
module GuestUbuntu module GuestUbuntu
class Guest < VagrantPlugins::GuestDebian::Guest class Guest < VagrantPlugins::GuestDebian::Guest

View File

@ -2,13 +2,14 @@ require "vagrant"
module VagrantPlugins module VagrantPlugins
module GuestUbuntu module GuestUbuntu
autoload :Guest, File.expand_path("../guest", __FILE__)
class Plugin < Vagrant.plugin("1") class Plugin < Vagrant.plugin("1")
name "Ubuntu guest" name "Ubuntu guest"
description "Ubuntu guest support." description "Ubuntu guest support."
guest("ubuntu") { Guest } guest("ubuntu") do
require File.expand_path("../guest", __FILE__)
Guest
end
end end
end end
end end