]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blobdiff - lib/CPANPLUS/Dist/Gentoo/Maps.pm
This is 0.07
[perl/modules/CPANPLUS-Dist-Gentoo.git] / lib / CPANPLUS / Dist / Gentoo / Maps.pm
index d118edc2361f13cbb1e7cb94f2fc9d2396998830..94d2e1603234a0c85117c0a02dfa8585f5af80c8 100644 (file)
@@ -9,11 +9,11 @@ CPANPLUS::Dist::Gentoo::Maps - Map CPAN objects to Gentoo and vice versa.
 
 =head1 VERSION
 
-Version 0.05
+Version 0.07
 
 =cut
 
-our $VERSION = '0.05';
+our $VERSION = '0.07';
 
 =head1 DESCRPITON
 
@@ -40,6 +40,67 @@ sub name_c2g {
  return $gentooisms{$name} || $name;
 }
 
+=head2 C<version_c2g $version>
+
+Converts a CPAN version to a Gentoo version.
+
+=cut
+
+sub version_c2g {
+ my ($v) = @_;
+
+ $v =~ y/-/_/;
+ $v =~ y/0-9._//cd;
+
+ $v =~ s/^[._]*//;
+ $v =~ s/[._]*$//;
+ $v =~ s/([._])[._]*/$1/g;
+
+ ($v, my $patch, my @rest) = split /_/, $v;
+ $v .= '_p' . $patch if defined $patch;
+ $v .= join('.', '', @rest) if @rest;
+
+ return $v;
+}
+
+=head2 C<version_gcmp $va, $vb>
+
+Compares two Gentoo versions.
+
+=cut
+
+sub version_gcmp {
+ my ($a, $b) = map { defined() ? $_ : 0 } @_;
+
+ for ($a, $b) {
+  s/^[._]+//g;
+  s/[._]+$//g;
+  if (/^([\d.]*\d)\.*(?:_p\.*(\d[\d.]*))?\.*(?:-r(\d+))?$/) {
+   $_ = {
+    v => [ split /\.+/, $1 ],
+    p => [ split /\.+/, $2 || 0 ],
+    r => [ $3 || 0 ],
+   };
+  } else {
+   require Carp;
+   Carp::croak("Couldn't parse version string '$_'");
+  }
+ }
+
+ for my $k (qw/v p r/) {
+  my $xa = $a->{$k};
+  my $xb = $b->{$k};
+  while (@$xa or @$xb) {
+   my $na = shift(@$xa) || 0;
+   my $nb = shift(@$xb) || 0;
+   my $c  = $na <=> $nb;
+   return $c if $c;
+  }
+ }
+
+ return 0;
+}
+
 =head1 SEE ALSO
 
 L<CPANPLUS::Dist::Gentoo>.
@@ -72,6 +133,7 @@ This program is free software; you can redistribute it and/or modify it under th
 
 __DATA__
 ANSIColor               Term-ANSIColor
+AcePerl                 Ace
 Audio-CD                Audio-CD-disc-cover
 CGI-Simple              Cgi-Simple
 Cache-Mmap              cache-mmap
@@ -127,6 +189,7 @@ Net-Server              net-server
 OLE-Storage_Lite        OLE-StorageLite
 Ogg-Vorbis-Header       ogg-vorbis-header
 PathTools               File-Spec
+Perl-Tidy               perltidy
 Pod-Parser              PodParser
 Regexp-Common           regexp-common
 SDL_Perl                sdl-perl