Class: Vagrant::Bundler::BuiltinSet

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

Overview

This is a custom Gem::Resolver::Set for use with vagrant "system" gems. It allows the installed set of gems to be used for providing a solution while enforcing strict constraints. This ensures that plugins cannot "upgrade" gems that are builtin to vagrant itself.

Instance Method Summary collapse

Constructor Details

#initializeBuiltinSet

Returns a new instance of BuiltinSet.



836
837
838
839
840
# File 'lib/vagrant/bundler.rb', line 836

def initialize
  super
  @remote = false
  @specs = []
end

Instance Method Details

#add_builtin_spec(spec) ⇒ Object



842
843
844
# File 'lib/vagrant/bundler.rb', line 842

def add_builtin_spec(spec)
  @specs.push(spec).uniq!
end

#find_all(req) ⇒ Object



846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
# File 'lib/vagrant/bundler.rb', line 846

def find_all(req)
  r = @specs.select do |spec|
    # When matching requests against builtin specs, we _always_ enable
    # prerelease matching since any prerelease that's found in this
    # set has been added explicitly and should be available for all
    # plugins to resolve against. This includes Vagrant itself since
    # it is considered a prerelease when in development mode
    req.match?(spec, true)
  end.map do |spec|
    Gem::Resolver::InstalledSpecification.new(self, spec)
  end
  # If any of the results are a prerelease, we need to mark the request
  # to allow prereleases so the solution can be properly fulfilled
  if r.any? { |x| x.version.prerelease? }
    req.dependency.prerelease = true
  end
  r
end