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 'tempfile'
require "vagrant"
require 'vagrant/util/template_renderer'
require Vagrant.source_root.join("plugins/guests/linux/guest")
module VagrantPlugins
module GuestArch
class Guest < VagrantPlugins::GuestLinux::Guest

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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