Do not load a plugin if it depends on invalid version of Vagrant

This commit is contained in:
Mitchell Hashimoto 2011-07-02 09:27:28 -07:00
parent 46c8bd09d3
commit 096c8b284f
2 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,7 @@
- Touch the network configuration file for RedHat so that the `sed` works - Touch the network configuration file for RedHat so that the `sed` works
with host only networking. [GH-381] with host only networking. [GH-381]
- Load prerelease versions of plugins if available. - Load prerelease versions of plugins if available.
- Do not load a plugin if it depends on an invalid version of Vagrant.
## 0.7.5 (May 16, 2011) ## 0.7.5 (May 16, 2011)

View File

@ -21,6 +21,9 @@ module Vagrant
# load path. This file is loaded to kick off the load sequence # load path. This file is loaded to kick off the load sequence
# for that plugin. # for that plugin.
def self.load! def self.load!
# Our version is used for checking dependencies
our_version = Gem::Version.create(Vagrant::VERSION)
# RubyGems 1.8.0 deprecated `source_index`. Gem::Specification is the # RubyGems 1.8.0 deprecated `source_index`. Gem::Specification is the
# new replacement. For now, we support both, but special-case 1.8.x # new replacement. For now, we support both, but special-case 1.8.x
# so that we avoid deprecation messages. # so that we avoid deprecation messages.
@ -38,6 +41,12 @@ module Vagrant
specs = Gem::VERSION >= "1.6.0" ? source.latest_specs(true) : source.latest_specs specs = Gem::VERSION >= "1.6.0" ? source.latest_specs(true) : source.latest_specs
specs.each do |spec| specs.each do |spec|
# If this gem depends on Vagrant, verify this is a valid release of
# Vagrant for this gem to load into.
vagrant_dep = spec.dependencies.find { |d| d.name == "vagrant" }
next if vagrant_dep && !vagrant_dep.requirement.satisfied_by?(our_version)
# Find a vagrant_init.rb to verify if this is a plugin
file = nil file = nil
if Gem::VERSION >= "1.8.0" if Gem::VERSION >= "1.8.0"
file = spec.matches_for_glob("**/vagrant_init.rb").first file = spec.matches_for_glob("**/vagrant_init.rb").first