class Bundler::Resolver
def resolve_requirement(spec_group, requirement, reqs, activated)
def resolve_requirement(spec_group, requirement, reqs, activated) # We are going to try activating the spec. We need to keep track of stack of # requirements that got us to the point of activating this gem. spec_group.required_by.replace requirement.required_by spec_group.required_by << requirement activated[spec_group.name] = spec_group debug { " Activating: #{spec_group.name} (#{spec_group.version})" } debug { spec_group.required_by.map { |d| " * #{d.name} (#{d.requirement})" }.join("\n") } dependencies = spec_group.activate_platform(requirement.__platform) # Now, we have to loop through all child dependencies and add them to our # array of requirements. debug { " Dependencies"} dependencies.each do |dep| next if dep.type == :development debug { " * #{dep.name} (#{dep.requirement})" } dep.required_by.replace(requirement.required_by) dep.required_by << requirement reqs << dep end # We create a savepoint and mark it by the name of the requirement that caused # the gem to be activated. If the activated gem ever conflicts, we are able to # jump back to this point and try another version of the gem. length = @stack.length @stack << requirement.name retval = catch(requirement.name) do resolve(reqs, activated) end # Since we're doing a lot of throw / catches. A push does not necessarily match # up to a pop. So, we simply slice the stack back to what it was before the catch # block. @stack.slice!(length..-1) retval end