Module: Bundler::Patch::ConservativeDefinition

Defined in:
lib/bundler/patch/conservative_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gems_to_updateObject

Returns the value of attribute gems_to_update.



3
4
5
# File 'lib/bundler/patch/conservative_definition.rb', line 3

def gems_to_update
  @gems_to_update
end

#minor_allowedObject

pass-through options to ConservativeResolver



6
7
8
# File 'lib/bundler/patch/conservative_definition.rb', line 6

def minor_allowed
  @minor_allowed
end

#strictObject

pass-through options to ConservativeResolver



6
7
8
# File 'lib/bundler/patch/conservative_definition.rb', line 6

def strict
  @strict
end

Instance Method Details

#resolveObject

This copies more code than I’d like out of Bundler::Definition, but for now seems the least invasive way in. Backing up and intervening into the creation of a Definition instance itself involves a lot more code, a lot more preliminary data has to be gathered first.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/bundler/patch/conservative_definition.rb', line 11

def resolve
  @resolve ||= begin
    last_resolve = converge_locked_specs
    if Bundler.settings[:frozen] || (!@unlocking && nothing_changed?)
      last_resolve
    else
      # Run a resolve against the locally available gems
      base = last_resolve.is_a?(Bundler::SpecSet) ? Bundler::SpecSet.new(last_resolve) : []
      resolver = ConservativeResolver.new(index, source_requirements, base)
      locked_specs = if @unlocking && @locked_specs.length == 0
                       # Have to grab these again. Default behavior is to not store any
                       # locked_specs if updating all gems, because behavior is the same
                       # with no lockfile OR lockfile but update them all. In our case,
                       # we need to know the locked versions for conservative comparison.
                       locked = Bundler::LockfileParser.new(@lockfile_contents)
                       Bundler::SpecSet.new(locked.specs)
                     else
                       @locked_specs
                     end

      resolver.gems_to_update = @gems_to_update
      resolver.locked_specs = locked_specs
      resolver.strict = @strict
      resolver.minor_allowed = @minor_allowed
      result = resolver.start(expanded_dependencies)
      spec_set = Bundler::SpecSet.new(result)

      last_resolve.merge spec_set
    end
  end
end