commit fae921649228e3679d1ca173e019bb51da0eced6 Author: Yossef Mendelssohn Date: Thu Apr 16 02:01:25 2009 -0500 Tweaking version to make trailing zeroes significant. 1.0.0 > 1.0 ftw diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb index d996538..cc748a3 100644 --- a/lib/rubygems/version.rb +++ b/lib/rubygems/version.rb @@ -129,10 +129,7 @@ class Gem::Version def normalize parts_arr = parse_parts_from_version_string - if parts_arr.length != 1 - parts_arr.pop while parts_arr.last && parts_arr.last.value == 0 - parts_arr = [Part.new(0)] if parts_arr.empty? - end + parts_arr = [Part.new(0)] if parts_arr.empty? parts_arr end @@ -172,14 +169,16 @@ class Gem::Version def <=>(other) return nil unless self.class === other return 1 unless other - mine, theirs = balance(self.parts.dup, other.parts.dup) + mine, theirs = balance(self, other) mine <=> theirs end def balance(a, b) - a << Part.new(0) while a.size < b.size - b << Part.new(0) while b.size < a.size - [a, b] + a_parts = a.parts.dup + b_parts = b.parts.dup + a_parts << Part.new(0) while a_parts.size < b_parts.size and b.prerelease? + b_parts << Part.new(0) while b_parts.size < a_parts.size and a.prerelease? + [a_parts, b_parts] end ##