Plugins. Documentation coming shortly.
This commit is contained in:
parent
759bbd046b
commit
d5fbf29ec0
|
@ -1,5 +1,9 @@
|
|||
## 0.6.0 (unreleased)
|
||||
|
||||
- **Plugins** have landed. Plugins are simply gems which have a `vagrant_init.rb`
|
||||
file somewhere in their load path. Please read the documentation on
|
||||
vagrantup.com before attempting to create a plugin (which is very easy)
|
||||
for more information on how it all works and also some guidelines.
|
||||
- `vagrant package` now takes a `--vagrantfile` option to specify a
|
||||
Vagrantfile to package. The `--include` approach for including a Vagrantfile
|
||||
no longer works (previously built boxes will continue to work).
|
||||
|
|
|
@ -14,6 +14,7 @@ module Vagrant
|
|||
autoload :Config, 'vagrant/config'
|
||||
autoload :DataStore, 'vagrant/data_store'
|
||||
autoload :Errors, 'vagrant/errors'
|
||||
autoload :Plugin, 'vagrant/plugin'
|
||||
autoload :Util, 'vagrant/util'
|
||||
|
||||
module Command
|
||||
|
@ -48,5 +49,6 @@ Vagrant::Util::GlobLoader.glob_require(libdir, %w{
|
|||
downloaders/base provisioners/base provisioners/chef systems/base
|
||||
hosts/base})
|
||||
|
||||
# Initialize the built-in actions
|
||||
# Initialize the built-in actions and load the plugins.
|
||||
Vagrant::Action.builtin!
|
||||
Vagrant::Plugin.load!
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
require "rubygems"
|
||||
|
||||
module Vagrant
|
||||
class Plugin
|
||||
# The array of loaded plugins.
|
||||
@@plugins = []
|
||||
|
||||
attr_reader :gemspec
|
||||
attr_reader :file
|
||||
|
||||
# Loads all the plugins for Vagrant. Plugins are currently
|
||||
# gems which have a "vagrant_init.rb" somewhere on their
|
||||
# load path. This file is loaded to kick off the load sequence
|
||||
# for that plugin.
|
||||
def self.load!
|
||||
# Look for a vagrant_init.rb in all the gems, but only the
|
||||
# latest version of the gems.
|
||||
Gem.source_index.latest_specs.each do |spec|
|
||||
file = Gem.searcher.matching_files(spec, "vagrant_init.rb").first
|
||||
next if !file
|
||||
|
||||
@@plugins << new(spec, file)
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the array of plugins which are currently loaded by
|
||||
# Vagrant.
|
||||
def self.plugins; @@plugins; end
|
||||
|
||||
# Initializes a new plugin, given a Gemspec and the path to the
|
||||
# gem's `vagrant_init.rb` file. This should never be called manually.
|
||||
# Instead {load!} creates all the instances.
|
||||
def initialize(spec, file)
|
||||
@gemspec = spec
|
||||
@file = file
|
||||
|
||||
load file
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
require "test_helper"
|
||||
|
||||
class PluginTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@klass = Vagrant::Plugin
|
||||
end
|
||||
|
||||
# This is a pretty tough class to test. TODO.
|
||||
end
|
Loading…
Reference in New Issue