Class: Vagrant::Bundler::VagrantSet
- Inherits:
-
Gem::Resolver::InstallerSet
- Object
- Gem::Resolver::InstallerSet
- Vagrant::Bundler::VagrantSet
- Defined in:
- lib/vagrant/bundler.rb
Overview
This is a custom Gem::Resolver::InstallerSet. It will prefer sources which are explicitly provided over default sources when matches are found. This is generally the entire set used for performing full resolutions on install.
Instance Attribute Summary collapse
-
#prefer_sources ⇒ Object
Returns the value of attribute prefer_sources.
-
#system_plugins ⇒ Object
Returns the value of attribute system_plugins.
Instance Method Summary collapse
-
#find_all(req) ⇒ Object
Allow InstallerSet to find matching specs, then filter for preferred sources.
-
#initialize(domain, defined_sources = {}) ⇒ VagrantSet
constructor
A new instance of VagrantSet.
Constructor Details
#initialize(domain, defined_sources = {}) ⇒ VagrantSet
Returns a new instance of VagrantSet.
813 814 815 816 817 |
# File 'lib/vagrant/bundler.rb', line 813 def initialize(domain, defined_sources={}) @prefer_sources = defined_sources @system_plugins = [] super(domain) end |
Instance Attribute Details
#prefer_sources ⇒ Object
Returns the value of attribute prefer_sources.
810 811 812 |
# File 'lib/vagrant/bundler.rb', line 810 def prefer_sources @prefer_sources end |
#system_plugins ⇒ Object
Returns the value of attribute system_plugins.
811 812 813 |
# File 'lib/vagrant/bundler.rb', line 811 def system_plugins @system_plugins end |
Instance Method Details
#find_all(req) ⇒ Object
Allow InstallerSet to find matching specs, then filter for preferred sources
821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 |
# File 'lib/vagrant/bundler.rb', line 821 def find_all(req) result = super if system_plugins.include?(req.name) result.delete_if do |spec| spec.is_a?(Gem::Resolver::InstalledSpecification) end end subset = result.find_all do |idx_spec| preferred = false if prefer_sources[req.name] if idx_spec.source.respond_to?(:path) preferred = prefer_sources[req.name].include?(idx_spec.source.path.to_s) end if !preferred preferred = prefer_sources[req.name].include?(idx_spec.source.uri.to_s) end end preferred end subset.empty? ? result : subset end |