Permalink
Browse files

Use Vincents cpan-to-gentoo translation

  • Loading branch information...
1 parent eb68c68 commit 61aa028395ac398af2de2891c26992291e58012e @kentfredric kentfredric committed Jan 9, 2011
Showing with 26 additions and 3 deletions.
  1. +24 −3 lib/Gentoo/PerlMod/Version.pm
  2. +2 −0 t/01_basic.t
@@ -300,11 +300,32 @@ sub _lax_cleaning_2 {
sub _expand_numeric {
my $perlver = shift;
- my $numeric = version->parse($perlver)->numify;
+ my $ver = version->parse($perlver)->normal;
- 1 while $numeric =~ s/([.]\d\d\d)(\d+)$/$1.$2/;
+ $ver =~ s/^v//; # strip leading v
+ $ver =~ s/(?:\.0+)*//; # strip excess .0 groups
- return $numeric;
+ my @tokens = split /\./, $ver;
+ my @out;
+
+ for (@tokens) {
+ $_ =~ s/^0+([1-9])/$1/; # strip leading 0's
+ push @out, $_;
+ }
+
+ return join q{.}, @out;
}
+=head1 THANKS
+
+=over4
+
+=item Torsten Veller
+
+=item Vincent Pit
+
+=back
+
+=cut
+
1;
View
@@ -83,4 +83,6 @@ is( gentooize_version( '1.6.AA', { lax => 2 } ), '1.006.370', 'x.y.ASCI
is( gentooize_version( '1.6.AAA', { lax => 2 } ), '1.006.370.010', 'x.y.ASCII' ); # 62
is( gentooize_version( '1.6.AAAA', { lax => 2 } ), '1.006.370.370', 'x.y.ASCII' ); # 63
is( gentooize_version( '1.6.A6FGHKE', { lax => 2 } ), '1.006.366.556.632.014', 'x.y.ASCII' ); # 64
+
+is( gentooize_version('1.1000.10'), '1.1000.10', '4-digit-middle-bit');
done_testing;

0 comments on commit 61aa028

Please sign in to comment.