class Bundler::Resolver::Base

Attributes

packages[R]
requirements[R]
source_requirements[R]

Public Class Methods

new(source_requirements, dependencies, base, platforms, options) click to toggle source
# File bundler/resolver/base.rb, line 10
def initialize(source_requirements, dependencies, base, platforms, options)
  @source_requirements = source_requirements

  @base = base

  @packages = Hash.new do |hash, name|
    hash[name] = Package.new(name, platforms, **options)
  end

  @requirements = dependencies.map do |dep|
    dep_platforms = dep.gem_platforms(platforms)

    # Dependencies scoped to external platforms are ignored
    next if dep_platforms.empty?

    name = dep.name

    @packages[name] = Package.new(name, dep_platforms, **options.merge(:dependency => dep))

    dep
  end.compact
end

Public Instance Methods

[](name) click to toggle source
# File bundler/resolver/base.rb, line 33
def [](name)
  @base[name]
end
base_requirements() click to toggle source
# File bundler/resolver/base.rb, line 47
def base_requirements
  @base_requirements ||= build_base_requirements
end
delete(specs) click to toggle source
# File bundler/resolver/base.rb, line 37
def delete(specs)
  specs.each do |spec|
    @base.delete(spec)
  end
end
get_package(name) click to toggle source
# File bundler/resolver/base.rb, line 43
def get_package(name)
  @packages[name]
end
include_prereleases(names) click to toggle source
# File bundler/resolver/base.rb, line 67
def include_prereleases(names)
  names.each do |name|
    get_package(name).consider_prereleases!
  end
end
unlock_names(names) click to toggle source
# File bundler/resolver/base.rb, line 51
def unlock_names(names)
  indirect_pins = indirect_pins(names)

  if indirect_pins.any?
    loosen_names(indirect_pins)
  else
    pins = pins(names)

    if pins.any?
      loosen_names(pins)
    else
      unrestrict_names(names)
    end
  end
end

Private Instance Methods

build_base_requirements() click to toggle source
# File bundler/resolver/base.rb, line 99
def build_base_requirements
  base_requirements = {}
  @base.each do |ls|
    req = Gem::Requirement.new(ls.version)
    base_requirements[ls.name] = req
  end
  base_requirements
end
indirect_pins(names) click to toggle source
# File bundler/resolver/base.rb, line 75
def indirect_pins(names)
  names.select {|name| @base_requirements[name].exact? && @requirements.none? {|dep| dep.name == name } }
end
loosen_names(names) click to toggle source
# File bundler/resolver/base.rb, line 83
def loosen_names(names)
  names.each do |name|
    version = @base_requirements[name].requirements.first[1]

    @base_requirements[name] = Gem::Requirement.new(">= #{version}")

    @base.delete_by_name(name)
  end
end
pins(names) click to toggle source
# File bundler/resolver/base.rb, line 79
def pins(names)
  names.select {|name| @base_requirements[name].exact? }
end
unrestrict_names(names) click to toggle source
# File bundler/resolver/base.rb, line 93
def unrestrict_names(names)
  names.each do |name|
    @base_requirements.delete(name)
  end
end