forked from hashicorp/vagrant
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Plugins. Documentation coming shortly.
- Loading branch information
Showing
4 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |