]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blobdiff - lib/CPANPLUS/Dist/Gentoo/Atom.pm
Infer the right category and name when creating an atom from an ebuild or a string
[perl/modules/CPANPLUS-Dist-Gentoo.git] / lib / CPANPLUS / Dist / Gentoo / Atom.pm
index 45a68c5b90ff08b05c92b5c13d7da886e204cbb0..ebe6a4e64d8e393c58c5af2ae3c7d6608becf8d0 100644 (file)
@@ -23,21 +23,21 @@ sub new {
 
  my %args = @_;
 
- my ($name, $category, $version);
+ my ($category, $name, $version);
  if (defined $args{name}) {
-  ($name, $category, $version) = @args{qw/name category version/};
+  ($category, $name, $version) = @args{qw/category name version/};
   Carp::confess('Category unspecified') unless defined $category;
   /[^\w-]/ and Carp::confess('Invalid argument') for $name, $category;
  } elsif (defined $args{atom}) {
   my $atom = $args{atom};
   $atom =~ m{^([\w-]+)/([\w-]+)-v?($version_rx)$}
                                                or Carp::confess('Invalid atom');
-  ($name, $category, $version) = ($1, $2, $3);
+  ($category, $name, $version) = ($1, $2, $3);
  } elsif (defined $args{ebuild}) {
   my $ebuild = $args{ebuild};
-  $ebuild =~ m{/([\w-]+)/([\w-]+)-v?($version_rx)\.ebuild$}
+  $ebuild =~ m{/([\w-]+)/([\w-]+)/\2-v?($version_rx)\.ebuild$}
                                              or Carp::confess('Invalid ebuild');
-  ($name, $category, $version) = ($1, $2, $3);
+  ($category, $name, $version) = ($1, $2, $3);
  } else {
   Carp::confess('Not enough information for building an atom object');
  }
@@ -55,7 +55,7 @@ sub new {
  bless {
   category => $category,
   name     => $name,
-  version  => $name,
+  version  => $version,
   minimum  => $args{minimum},
   ebuild   => $args{ebuild},
  }, $class;
@@ -120,7 +120,7 @@ sub fold {
   }
 
   if ($atom->minimum) {
-   if ($cur->minmium) {
+   if ($cur->minimum) {
     $seen{$key} = $atom < $cur ? $cur : $atom;
    } else {
     Carp::confess('Version mismatch') if $atom > $cur;