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.



839
840
841
842
843
# File 'lib/vagrant/bundler.rb', line 839

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

Instance Method Details

#add_builtin_spec(spec) ⇒ Object



845
846
847
# File 'lib/vagrant/bundler.rb', line 845

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

#find_all(req) ⇒ Object



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

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