Class: Vagrant::Bundler::PluginSet

Inherits:
Gem::Resolver::VendorSet
  • Object
show all
Defined in:
lib/vagrant/bundler.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#add_vendor_gem(name, directory) ⇒ Object

Adds a specification to the set with the given +name+ which has been unpacked into the given +directory+.



831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
# File 'lib/vagrant/bundler.rb', line 831

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) ⇒ Object

Returns an Array of VendorSpecification objects matching the DependencyRequest +req+.



852
853
854
855
856
857
858
859
# File 'lib/vagrant/bundler.rb', line 852

def find_all(req)
  @specs.values.flatten.select do |spec|
    req.match?(spec)
  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) ⇒ Object

Loads a spec with the given +name+. +version+, +platform+ and +source+ are ignored.



864
865
866
867
# File 'lib/vagrant/bundler.rb', line 864

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