No more RubyGems deprecation messages!

This commit is contained in:
Mitchell Hashimoto 2011-05-16 12:32:33 -07:00
parent 45f4b0cd7f
commit f96a6363e2
2 changed files with 18 additions and 4 deletions

View File

@ -2,6 +2,7 @@
- `config.ssh.port` can be specified and takes highest precedence if specified.
Otherwise, Vagrant will still attempt to auto-detect the port. [GH-363]
- Get rid of RubyGems deprecations introduced with RubyGems 1.8.x
## 0.7.4 (May 12, 2011)

View File

@ -21,18 +21,31 @@ module Vagrant
# load path. This file is loaded to kick off the load sequence
# for that plugin.
def self.load!
# RubyGems 1.8.0 deprecated `source_index`. Gem::Specification is the
# new replacement. For now, we support both, but special-case 1.8.x
# so that we avoid deprecation messages.
index = Gem::VERSION >= "1.8.0" ? Gem::Specification : Gem.source_index
# 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.
[index].flatten.each do |source|
source.latest_specs.each do |spec|
file = Gem.searcher.matching_files(spec, "vagrant_init.rb").first
next if !file
# In 1.6.0, added the option of including prerelease gems, which is
# useful for developers.
specs = Gem::VERSION >= "1.6.0" ? source.latest_specs(true) : source.latest_specs
source.latest_specs.each do |spec|
file = nil
if Gem::VERSION >= "1.8.0"
file = spec.matches_for_glob("**/vagrant_init.rb").first
else
file = Gem.searcher.matching_files(spec, "vagrant_init.rb").first
end
next if !file
@@plugins << new(spec, file)
end
end