]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blobdiff - lib/CPANPLUS/Dist/Gentoo/Atom.pm
Allow the correct package names in atoms
[perl/modules/CPANPLUS-Dist-Gentoo.git] / lib / CPANPLUS / Dist / Gentoo / Atom.pm
index 5607de7cd2e8f242345e8c92dcf4d5e0fa31dad9..33c622c1622e54b3f3641ebe24cbee44d2b63154 100644 (file)
@@ -5,15 +5,15 @@ use warnings;
 
 =head1 NAME
 
-CPANPLUS::Dist::Gentoo::Version - Gentoo atom object.
+CPANPLUS::Dist::Gentoo::Atom - Gentoo atom object.
 
 =head1 VERSION
 
-Version 0.09
+Version 0.10
 
 =cut
 
-our $VERSION = '0.09';
+our $VERSION = '0.10';
 
 =head1 DESCRIPTION
 
@@ -32,7 +32,10 @@ use overload (
 
 use CPANPLUS::Dist::Gentoo::Version;
 
-my $version_rx = $CPANPLUS::Dist::Gentoo::Version::version_rx;
+my $range_rx    = qr/(?:<|<=|=|>=|>)/;
+my $name_rx     = qr/[a-zA-Z0-9_+-]+/;
+my $category_rx = $name_rx;
+my $version_rx  = $CPANPLUS::Dist::Gentoo::Version::version_rx;
 
 =head1 METHODS
 
@@ -52,10 +55,11 @@ sub new {
  if (defined $args{name}) {
   ($range, $category, $name, $version) = @args{qw/range category name version/};
   Carp::confess('Category unspecified') unless defined $category;
-  /[^\w-]/ and Carp::confess('Invalid argument') for $name, $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{^(<|<=|=|>=|>)?([\w-]+)/([\w-]+)(?:-v?($version_rx))?$}
+  $atom =~ m{^($range_rx)?($category_rx)/($name_rx)(?:-v?($version_rx))?$}o
                                                or Carp::confess('Invalid atom');
   ($range, $category, $name, $version) = ($1, $2, $3, $4);
  } else {
@@ -71,10 +75,9 @@ sub new {
 
  if (defined $version) {
   if (defined $range) {
-   Carp::confess("Invalid range $range")
-                                      unless grep $range eq $_, qw|< <= = >= >|;
+   Carp::confess("Invalid range $range") unless $range =~ /^$range_rx$/o;
   } else {
-   $range = '=';
+   $range = '>=';
   }
  } else {
   Carp::confess('Range atoms require a valid version')
@@ -103,7 +106,7 @@ sub new_from_ebuild {
  my $ebuild = shift;
  $ebuild = '' unless defined $ebuild;
 
- $ebuild =~ m{/([\w-]+)/([\w-]+)/\2-v?($version_rx)\.ebuild$}
+ $ebuild =~ m{/($category_rx)/($name_rx)/\2-v?($version_rx)\.ebuild$}o
                                              or Carp::confess('Invalid ebuild');
  my ($category, $name, $version) = ($1, $2, $3);
 
@@ -310,7 +313,8 @@ 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.
+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
 
@@ -320,7 +324,7 @@ You can find documentation for this module with the perldoc command.
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2009 Vincent Pit, all rights reserved.
+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.