From: Vincent Pit Date: Sun, 29 Nov 2009 00:24:03 +0000 (+0100) Subject: Introduce C::D::G::Atom->qualified_name X-Git-Tag: v0.09~12 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git;a=commitdiff_plain;h=1501f44a9ccfe05c7525b70b7f1470bbb26453fd Introduce C::D::G::Atom->qualified_name --- diff --git a/lib/CPANPLUS/Dist/Gentoo/Atom.pm b/lib/CPANPLUS/Dist/Gentoo/Atom.pm index a560326..8ee0f88 100644 --- a/lib/CPANPLUS/Dist/Gentoo/Atom.pm +++ b/lib/CPANPLUS/Dist/Gentoo/Atom.pm @@ -75,6 +75,8 @@ BEGIN { eval "sub $_ { \$_[0]->{$_} }" for qw/category name version range ebuild/; } +sub qualified_name { join '/', $_[0]->category, $_[0]->name } + sub _spaceship { my ($a1, $a2, $r) = @_; @@ -97,7 +99,7 @@ sub _spaceship { sub _stringify { my ($a) = @_; - my $atom = $a->category . '/' . $a->name; + my $atom = $a->qualified_name; my $version = $a->version; $atom = $a->range . $atom . '-' . $version if defined $version; @@ -120,8 +122,8 @@ sub and { my $a2 = shift; $a2 = $a2->and(@_) if @_; - my $p1 = join '/', $a1->category, $a1->name; - my $p2 = join '/', $a2->category, $a2->name; + my $p1 = $a1->qualified_name; + my $p2 = $a2->qualified_name; Carp::confess("Atoms for different packages $p1 and $p2") unless $p1 eq $p2; my $v1 = $a1->version; @@ -160,7 +162,7 @@ sub fold { my %seen; for my $atom (@_) { - my $key = join '/', $atom->category, $atom->name; + my $key = $atom->qualified_name; my $cur = $seen{$key}; $seen{$key} = defined $cur ? $cur->and($atom) : $atom;