diff --git a/CHANGELOG.md b/CHANGELOG.md index a7f921b39..4856fa5b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/vagrant/plugin.rb b/lib/vagrant/plugin.rb index 5df4e89d0..b6f92fc41 100644 --- a/lib/vagrant/plugin.rb +++ b/lib/vagrant/plugin.rb @@ -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