]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blobdiff - lib/CPANPLUS/Dist/Gentoo/Atom.pm
Make 'ebuild' a normal accessor for C::D::G::Atom objects
[perl/modules/CPANPLUS-Dist-Gentoo.git] / lib / CPANPLUS / Dist / Gentoo / Atom.pm
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);
- } 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');
  }
@@ -72,6 +67,25 @@ sub new {
  }, $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/;
 }