class Bundler::PubGrub::VersionUnion

def self.normalize_ranges(ranges)

def self.normalize_ranges(ranges)
  ranges = ranges.flat_map do |range|
    range.ranges
  end
  ranges.reject!(&:empty?)
  return [] if ranges.empty?
  mins, ranges = ranges.partition { |r| !r.min }
  original_ranges = mins + ranges.sort_by { |r| [r.min, r.include_min ? 0 : 1] }
  ranges = [original_ranges.shift]
  original_ranges.each do |range|
    if ranges.last.contiguous_to?(range)
      ranges << ranges.pop.span(range)
    else
      ranges << range
    end
  end
  ranges
end