[Rubygems-developers] Gem#status?

Josh Susser josh at hasmanythrough.com
Wed Nov 12 06:17:21 EST 2008


On Nov 12, 2008, at 4:39 AM, Ryan Davis wrote:

>
> On Nov 11, 2008, at 10:59 , Phil Hagelberg wrote:
>
>> Really? String#<=> is pretty well-understood as far as I can tell.
>
>
> yes... it is very well understood to be very bad for this problem:
>
> >> "a2" <=> "a11"
> => 1
> >> 2 <=> 11
> => -1


So use a.1 and a.11 instead of a1 and a11

   def test_order
     numbers = %w[ 1.0.a 1.0.a.1 1.0.a.2 1.0.a.11 1.0.b.1 1 1.0.1 1.2 ]
     versions = numbers.collect { |n| Gem::Version.new(n) }
     assert_equal numbers, versions.sort.collect { |v|  
v.parts.join(".") }
   end



--
Josh Susser
http://blog.hasmanythrough.com




More information about the Rubygems-developers mailing list