]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blobdiff - lib/CPANPLUS/Dist/Gentoo/Version.pm
Regexp overhaul in CPANPLUS::Dist::Gentoo::Version
[perl/modules/CPANPLUS-Dist-Gentoo.git] / lib / CPANPLUS / Dist / Gentoo / Version.pm
index bdfd755ad13a8a64945a66b3084a56600e66ab3a..47cec967983590d1e9930f7587082142b0c4d3db 100644 (file)
@@ -3,19 +3,43 @@ package CPANPLUS::Dist::Gentoo::Version;
 use strict;
 use warnings;
 
+=head1 NAME
+
+CPANPLUS::Dist::Gentoo::Version - Gentoo version object.
+
+=head1 VERSION
+
+Version 0.10
+
+=cut
+
+our $VERSION = '0.10';
+
+=head1 DESCRIPTION
+
+This class models Gentoo versions.
+
+=cut
+
 use Scalar::Util ();
 
 use overload (
- '<=>' => \&cmp,
- '""'  => \&as_string,
+ '<=>' => \&_spaceship,
+ '""'  => \&_stringify,
 );
 
-our $VERSION = '0.08';
+my $int_rx        = qr/[0-9]+/;
+my $dotted_num_rx = qr/$int_rx(?:\.$int_rx)*/o;
 
-my $int_rx        = qr/\d+/;
-my $dotted_num_rx = qr/$int_rx(?:\.$int_rx)*/;
+our $version_rx = qr/$dotted_num_rx(?:_p$dotted_num_rx)?(?:-r$int_rx)?/o;
 
-our $version_rx = qr/$dotted_num_rx(?:_p$dotted_num_rx)?(?:-r$int_rx)?/;
+=head1 METHODS
+
+=head2 C<new $vstring>
+
+Creates a new L<CPANPLUS::Dist::Gentoo::Version> object from the version string C<$vstring>.
+
+=cut
 
 sub new {
  my $class = shift;
@@ -25,7 +49,7 @@ sub new {
  if (defined $vstring) {
   $vstring =~ s/^[._]+//g;
   $vstring =~ s/[._]+$//g;
-  if ($vstring =~ /^($dotted_num_rx)(?:_p($dotted_num_rx))?(?:-r($int_rx))?$/{
+  if ($vstring =~ /^($dotted_num_rx)(?:_p($dotted_num_rx))?(?:-r($int_rx))?$/o){
    return bless {
     string   => $vstring,
     version  => [ split /\.+/, $1 ],
@@ -45,7 +69,21 @@ BEGIN {
  eval "sub $_ { \$_[0]->{$_} }" for @parts;
 }
 
-sub cmp {
+=head2 C<version>
+
+Read-only accessor for the C<version> part of the version object.
+
+=head2 C<patch>
+
+Read-only accessor for the C<patch> part of the version object.
+
+=head2 C<revision>
+
+Read-only accessor for the C<revision> part of the version object.
+
+=cut
+
+sub _spaceship {
  my ($v1, $v2, $r) = @_;
 
  unless (Scalar::Util::blessed($v2) and $v2->isa(__PACKAGE__)) {
@@ -68,7 +106,7 @@ sub cmp {
  return 0;
 }
 
-sub as_string {
+sub _stringify {
  my ($v) = @_;
 
  my ($version, $patch, $revision) = map $v->$_, @parts;
@@ -80,4 +118,37 @@ sub as_string {
  $version;
 }
 
-1;
+=pod
+
+This class provides overloaded methods for numerical comparison and strigification.
+
+=head1 SEE ALSO
+
+L<CPANPLUS::Dist::Gentoo>.
+
+=head1 AUTHOR
+
+Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
+
+You can contact me by mail or on C<irc.perl.org> (vincent).
+
+=head1 BUGS
+
+Please report any bugs or feature requests to C<bug-cpanplus-dist-gentoo at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPANPLUS-Dist-Gentoo>.
+I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+    perldoc CPANPLUS::Dist::Gentoo
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2009,2010 Vincent Pit, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
+
+=cut
+
+1; # End of CPANPLUS::Dist::Gentoo::Version