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.


831
832
833
834
835
# File 'lib/vagrant/bundler.rb', line 831

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

Instance Method Details

#add_builtin_spec(spec) ⇒ Object


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

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

#find_all(req) ⇒ Object


841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
# File 'lib/vagrant/bundler.rb', line 841

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