class Bundler::Patch::GemVersionPatchPromoter
Attributes
gems_to_update[RW]
minimal[RW]
Private Instance Methods
both_versions_gt_or_equal_to_version(version)
click to toggle source
# File lib/bundler/patch/gem_version_patch_promoter.rb, line 49 def both_versions_gt_or_equal_to_version(version) version && @a_ver >= version && @b_ver >= version end
neither_version_matches(match_version)
click to toggle source
# File lib/bundler/patch/gem_version_patch_promoter.rb, line 45 def neither_version_matches(match_version) !one_version_matches(match_version) end
one_version_matches(match_version)
click to toggle source
# File lib/bundler/patch/gem_version_patch_promoter.rb, line 41 def one_version_matches(match_version) [@a_ver, @b_ver].include?(match_version) end
post_sort(result)
click to toggle source
Sorting won't work properly for some specific arrangements to the end of the list because not all versions are compared in quicksort and the result isn't deterministic.
Calls superclass method
# File lib/bundler/patch/gem_version_patch_promoter.rb, line 55 def post_sort(result) result = super(result) if @new_version && unlocking_gem? && segments_match(:major, @new_version, @locked_version) if @minimal || (!@minimal && result.last.version < @new_version) # This handles two cases: # - minimal doesn't want to go past requested new_version # - new_version is up a minor rev but level is :patch result = move_version_to_end(result, @new_version) end end result end
segments_match(level, a_ver, b_ver)
click to toggle source
# File lib/bundler/patch/gem_version_patch_promoter.rb, line 70 def segments_match(level, a_ver, b_ver) index = [:major, :minor].index(level) a_ver.segments[index] == b_ver.segments[index] end
sort_dep_specs(spec_groups, locked_spec)
click to toggle source
Calls superclass method
# File lib/bundler/patch/gem_version_patch_promoter.rb, line 7 def sort_dep_specs(spec_groups, locked_spec) result = super(spec_groups, locked_spec) return result unless locked_spec @gem_name = locked_spec.name @locked_version = locked_spec.version gem_patch = @gems_to_update.gem_patch_for(@gem_name) @new_version = gem_patch ? gem_patch.new_version : nil return result unless @minimal || @new_version # STDERR.puts "during sort_versions: #{debug_format_result(spec_groups.first.first.name, result).inspect}" if ENV["DEBUG_RESOLVER"] # Custom sort_by-ish behavior to minimize index calls. result = result.map { |a| [result.index(a), a] }.sort do |(a_index, a), (b_index, b)| @a_ver = a.version @b_ver = b.version case when @minimal && unlocking_gem? && (neither_version_matches(@locked_version) && (!@new_version || both_versions_gt_or_equal_to_version(@new_version))) @b_ver <=> @a_ver else a_index <=> b_index # no change in current ordering end end.map { |a| a.last } post_sort(result) end
unlocking_gem?()
click to toggle source
# File lib/bundler/patch/gem_version_patch_promoter.rb, line 37 def unlocking_gem? @gems_to_update.unlocking_gem?(@gem_name) end