Class: Bundler::Resolver::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/resolver/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_requirements, dependencies, base, platforms, options) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/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

Instance Attribute Details

#packagesObject (readonly)

Returns the value of attribute packages.



8
9
10
# File 'lib/bundler/resolver/base.rb', line 8

def packages
  @packages
end

#requirementsObject (readonly)

Returns the value of attribute requirements.



8
9
10
# File 'lib/bundler/resolver/base.rb', line 8

def requirements
  @requirements
end

#source_requirementsObject (readonly)

Returns the value of attribute source_requirements.



8
9
10
# File 'lib/bundler/resolver/base.rb', line 8

def source_requirements
  @source_requirements
end

Instance Method Details

#[](name) ⇒ Object



37
38
39
# File 'lib/bundler/resolver/base.rb', line 37

def [](name)
  @base[name]
end

#base_requirementsObject



49
50
51
# File 'lib/bundler/resolver/base.rb', line 49

def base_requirements
  @base_requirements ||= build_base_requirements
end

#delete(specs) ⇒ Object



41
42
43
# File 'lib/bundler/resolver/base.rb', line 41

def delete(specs)
  @base.delete(specs)
end

#get_package(name) ⇒ Object



45
46
47
# File 'lib/bundler/resolver/base.rb', line 45

def get_package(name)
  @packages[name]
end

#include_prereleases(names) ⇒ Object



69
70
71
72
73
# File 'lib/bundler/resolver/base.rb', line 69

def include_prereleases(names)
  names.each do |name|
    get_package(name).consider_prereleases!
  end
end

#include_remote_specs(names) ⇒ Object



75
76
77
78
79
# File 'lib/bundler/resolver/base.rb', line 75

def include_remote_specs(names)
  names.each do |name|
    get_package(name).consider_remote_versions!
  end
end

#specs_compatible_with(result) ⇒ Object



33
34
35
# File 'lib/bundler/resolver/base.rb', line 33

def specs_compatible_with(result)
  @base.specs_compatible_with(result)
end

#unlock_names(names) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/bundler/resolver/base.rb', line 53

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