class Vagrant::Bundler::PluginSet
This is a custom Gem::Resolver::Set for use with Vagrant
plugins. It is a modified Gem::Resolver::VendorSet that supports multiple versions of a specific gem
Public Instance Methods
add_vendor_gem(name, directory)
click to toggle source
Adds a specification to the set with the given name
which has been unpacked into the given directory
.
# File lib/vagrant/bundler.rb, line 873 def add_vendor_gem(name, directory) gemspec = File.join(directory, "#{name}.gemspec") spec = Gem::Specification.load(gemspec) if !spec raise Gem::GemNotFoundException, "unable to find #{gemspec} for gem #{name}" end spec.full_gem_path = File.expand_path(directory) spec.base_dir = File.dirname(spec.base_dir) @specs[spec.name] ||= [] @specs[spec.name] << spec @directories[spec] = directory spec end
find_all(req)
click to toggle source
Returns an Array of VendorSpecification objects matching the DependencyRequest req
.
# File lib/vagrant/bundler.rb, line 894 def find_all(req) @specs.values.flatten.select do |spec| req.match?(spec, prerelease) end.map do |spec| source = Gem::Source::Vendor.new(@directories[spec]) Gem::Resolver::VendorSpecification.new(self, spec, source) end end
load_spec(name, version, platform, source)
click to toggle source
Loads a spec with the given name
. version
, platform
and source
are ignored.
# File lib/vagrant/bundler.rb, line 906 def load_spec(name, version, platform, source) version = Gem::Version.new(version) if !version.is_a?(Gem::Version) @specs.fetch(name, []).detect{|s| s.name == name && s.version == version} end