Fix plugin loading in a Rails 2.3.x project [closes GH-176]

This commit is contained in:
Mitchell Hashimoto 2010-10-05 13:40:09 -07:00
parent 8d909b8ee4
commit 5b9bc086ac
2 changed files with 12 additions and 5 deletions

View File

@ -1,6 +1,6 @@
## 0.6.5 (unreleased)
- Fix plugin loading in a Rails 2.3.x project. [GH-176]
## 0.6.4 (October 4, 2010)

View File

@ -21,13 +21,20 @@ module Vagrant
# load path. This file is loaded to kick off the load sequence
# for that plugin.
def self.load!
# Stupid hack since Rails 2.3.x overrides Gem.source_index with their
# own incomplete replacement which causes issues.
index = Gem.source_index
index = [index.installed_source_index, index.vendor_source_index] if defined?(Rails::VendorGemSourceIndex) && index.is_a?(Rails::VendorGemSourceIndex)
# 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
[index].flatten.each do |source|
source.latest_specs.each do |spec|
file = Gem.searcher.matching_files(spec, "vagrant_init.rb").first
next if !file
@@plugins << new(spec, file)
@@plugins << new(spec, file)
end
end
end