]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blobdiff - lib/CPANPLUS/Dist/Gentoo/Atom.pm
Make sure the POD headings are linkable
[perl/modules/CPANPLUS-Dist-Gentoo.git] / lib / CPANPLUS / Dist / Gentoo / Atom.pm
index dfddd4254c407b04bed9735b223d47d02a508d3e..eef7cff2efc7d04c848985d2c199dc1113e4246f 100644 (file)
@@ -9,11 +9,11 @@ CPANPLUS::Dist::Gentoo::Atom - Gentoo atom object.
 
 =head1 VERSION
 
-Version 0.10
+Version 0.12
 
 =cut
 
-our $VERSION = '0.10';
+our $VERSION = '0.12';
 
 =head1 DESCRIPTION
 
@@ -39,7 +39,24 @@ my $version_rx  = $CPANPLUS::Dist::Gentoo::Version::version_rx;
 
 =head1 METHODS
 
-=head2 C<< new category => $category, name => $name [, version => $version, range => $range, ebuild => $ebuild ] >>
+=head2 C<new>
+
+    # Infer everything from $atom :
+    my $cdga = CPANPLUS::Dist::Gentoo::Atom->new(
+     atom     => $atom,
+     # Optional :
+     ebuild   => $ebuild,
+    );
+
+    # Or specify the attributes manually :
+    my $cdga = CPANPLUS::Dist::Gentoo::Atom->new(
+     category => $category,
+     name     => $name,
+     version  => $version,
+     range    => $range,
+     # Optional :
+     ebuild   => $ebuild,
+    );
 
 Creates a new L<CPANPLUS::Dist::Gentoo::Atom> object from the supplied C<$category>, C<$name>, C<$version>, C<$range> and C<$ebuild>.
 
@@ -53,13 +70,13 @@ sub new {
 
  my ($range, $category, $name, $version);
  if (defined $args{name}) {
-  ($range, $category, $name, $version) = @args{qw/range category name version/};
+  ($range, $category, $name, $version) = @args{qw<range category name version>};
   Carp::confess('Category unspecified') unless defined $category;
   Carp::confess('Invalid category')     unless $category =~ /^$category_rx$/o;
   Carp::confess('Invalid name')         unless $name     =~ /^$name_rx$/o;
  } elsif (defined $args{atom}) {
   my $atom = $args{atom};
-  $atom =~ m{^($range_rx)?($category_rx)/($name_rx)(?:-v?($version_rx))?$}o
+  $atom =~ m{^($range_rx)?($category_rx)/($name_rx)(?:-($version_rx))?$}o
                                                or Carp::confess('Invalid atom');
   ($range, $category, $name, $version) = ($1, $2, $3, $4);
  } else {
@@ -93,7 +110,9 @@ sub new {
  }, $class;
 }
 
-=head2 C<new_from_ebuild $ebuild>
+=head2 C<new_from_ebuild>
+
+    my $cdga = CPANPLUS::Dist::Gentoo::Atom->new_from_ebuild($ebuild);
 
 Creates a new L<CPANPLUS::Dist::Gentoo::Atom> object by inferring the category, name and version from the given C<$ebuild>
 
@@ -106,7 +125,7 @@ sub new_from_ebuild {
  my $ebuild = shift;
  $ebuild = '' unless defined $ebuild;
 
- $ebuild =~ m{/($category_rx)/($name_rx)/\2-v?($version_rx)\.ebuild$}o
+ $ebuild =~ m{/($category_rx)/($name_rx)/\2-($version_rx)\.ebuild$}o
                                              or Carp::confess('Invalid ebuild');
  my ($category, $name, $version) = ($1, $2, $3);
 
@@ -119,7 +138,7 @@ sub new_from_ebuild {
 }
 
 BEGIN {
- eval "sub $_ { \$_[0]->{$_} }" for qw/category name version range ebuild/;
+ eval "sub $_ { \$_[0]->{$_} }" for qw<category name version range ebuild>;
 }
 
 =head2 C<category>
@@ -228,7 +247,9 @@ my %order = (
  '>'  =>  2,
 );
 
-=head2 C<and @atoms>
+=head2 C<and>
+
+    my $cdga = CPANPLUS::Dist::Gentoo::Atom->and(@atoms);
 
 Compute the ranged atom representing the logical AND between C<@atoms> with the same category and name.
 
@@ -278,7 +299,9 @@ sub and {
  }
 }
 
-=head2 C<fold @atoms>
+=head2 C<fold>
+
+    my @folded = CPANPLUS::Dist::Gentoo::Atom->fold(@atoms);
 
 Returns a list built from C<@atoms> but where there's only one atom for a given category and name.
 
@@ -295,12 +318,12 @@ sub fold {
   $seen{$key} = defined $cur ? $cur->and($atom) : $atom;
  }
 
- return values %seen;
+ return map $seen{$_}, sort keys %seen;
 }
 
 =pod
 
-This class provides overloaded methods for numerical comparison, string comparison and strigification.
+This class provides overloaded methods for numerical comparison, string comparison and stringification.
 
 =head1 SEE ALSO
 
@@ -325,7 +348,7 @@ You can find documentation for this module with the perldoc command.
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2009,2010 Vincent Pit, all rights reserved.
+Copyright 2009,2010,2011,2012 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.