]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/commitdiff
Make 'ebuild' a normal accessor for C::D::G::Atom objects
authorVincent Pit <vince@profvince.com>
Sun, 29 Nov 2009 00:49:41 +0000 (01:49 +0100)
committerVincent Pit <vince@profvince.com>
Sun, 29 Nov 2009 01:07:37 +0000 (02:07 +0100)
Only infer the others components when C::D::G::Atom->new_from_ebuild is
called.

lib/CPANPLUS/Dist/Gentoo.pm
lib/CPANPLUS/Dist/Gentoo/Atom.pm

index f44b124fee5a427b5f83afd764b1b98433fa3a5f..307d802108c903dfda523ba9ce864ef69a7498f3 100644 (file)
@@ -566,20 +566,17 @@ sub _cpan2portage {
     "$name-*.ebuild",
    ) or next;
 
     "$name-*.ebuild",
    ) or next;
 
-   my @atoms = map CPANPLUS::Dist::Gentoo::Atom->new(
-    defined $version ? (
-     ebuild => $_,
-     range  => '>=',
-    ) : (
-     category => $category,
-     name     => $name,
-    ),
-   ), @ebuilds;
-
-   my $atom = reduce { $a < $b ? $b : $a } @atoms; # handles overloading
-   next if defined $version and $atom < $version;
-
-   return $atom;
+   my $last = reduce { $a < $b ? $b : $a } # handles overloading
+               map CPANPLUS::Dist::Gentoo::Atom->new_from_ebuild($_),
+                @ebuilds;
+   next if defined $version and $last < $version;
+
+   return CPANPLUS::Dist::Gentoo::Atom->new(
+    category => $last->category,
+    name     => $last->name,
+    (defined $version ? (version => $version, range => '>=') : ()),
+    ebuild   => $last->ebuild,
+   );
   }
 
  }
   }
 
  }
index 002b349be48a31dc5ff532f80760a49bf5456df6..543693e5ab7b8471dfdf10d1f73870fea153074c 100644 (file)
@@ -34,11 +34,6 @@ sub new {
   $atom =~ m{^([\w-]+)/([\w-]+)-v?($version_rx)$}
                                                or Carp::confess('Invalid atom');
   ($category, $name, $version) = ($1, $2, $3);
   $atom =~ m{^([\w-]+)/([\w-]+)-v?($version_rx)$}
                                                or Carp::confess('Invalid atom');
   ($category, $name, $version) = ($1, $2, $3);
- } elsif (defined $args{ebuild}) {
-  my $ebuild = $args{ebuild};
-  $ebuild =~ m{/([\w-]+)/([\w-]+)/\2-v?($version_rx)\.ebuild$}
-                                             or Carp::confess('Invalid ebuild');
-  ($category, $name, $version) = ($1, $2, $3);
  } else {
   Carp::confess('Not enough information for building an atom object');
  }
  } else {
   Carp::confess('Not enough information for building an atom object');
  }
@@ -72,6 +67,25 @@ sub new {
  }, $class;
 }
 
  }, $class;
 }
 
+sub new_from_ebuild {
+ my $class = shift;
+ $class = ref($class) || $class;
+
+ my $ebuild = shift;
+ $ebuild = '' unless defined $ebuild;
+
+ $ebuild =~ m{/([\w-]+)/([\w-]+)/\2-v?($version_rx)\.ebuild$}
+                                             or Carp::confess('Invalid ebuild');
+ my ($category, $name, $version) = ($1, $2, $3);
+
+ return $class->new(
+  category => $category,
+  name     => $name,
+  version  => $version,
+  ebuild   => $ebuild,
+ );
+}
+
 BEGIN {
  eval "sub $_ { \$_[0]->{$_} }" for qw/category name version range ebuild/;
 }
 BEGIN {
  eval "sub $_ { \$_[0]->{$_} }" for qw/category name version range ebuild/;
 }