X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FCollection%2FVersion.pm;h=f461afe3f99fc48f23817185bf226d74a4f4cb63;hb=466f7faff129a5699c7674f59900a92aa256175d;hp=b721cd915dd56951bee83d4b6a15a8df6d037d78;hpb=01c360c8831df87a69fe1f49a08dda22ded51950;p=debbugs.git diff --git a/Debbugs/Collection/Version.pm b/Debbugs/Collection/Version.pm index b721cd9..f461afe 100644 --- a/Debbugs/Collection/Version.pm +++ b/Debbugs/Collection/Version.pm @@ -12,6 +12,9 @@ Debbugs::Collection::Version -- Version generation factory =head1 SYNOPSIS +This collection extends L and contains members of +L. Useful for any field which contains package versions. + =head1 DESCRIPTION @@ -32,6 +35,24 @@ use List::AllUtils qw(part); extends 'Debbugs::Collection'; +=head2 my $bugs = Debbugs::Collection::version->new(%params|$param) + +Parameters in addition to those defined by L + +=over + +=item package_collection + +Optional L which is used to look up packages + +=item versions + +Optional arrayref of C string triples + +=back + +=cut + has '+members' => (isa => 'ArrayRef[Debbugs::Version]'); has 'package_collection' => @@ -47,9 +68,9 @@ sub _build_package_collection { } sub member_key { - use Data::Printer; - p @_; - return $_[1]->package.'/'.$_[1]->version.'/'.$_[1]->arch; + my ($self,$v) = @_; + confess("v not defined") unless defined $v; + return $v->package.'/'.$v->version.'/'.$v->arch; } @@ -64,17 +85,15 @@ around add_by_key => sub { sub _member_constructor { my $self = shift; my %args = @_; - my @schema_arg; my @return; for my $pkg_ver_arch (make_list($args{versions})) { my ($pkg,$ver,$arch) = $pkg_ver_arch =~ m{^([^/]+)/([^/]+)/?([^/]*)$} or confess("Invalid version key: $pkg_ver_arch"); + if ($pkg =~ s/^src://) { + $arch = 'source'; + } if (not length $arch) { - if ($pkg =~ /^src:/) { - $arch = 'source'; - } else { - $arch = 'any'; - } + $arch = 'any'; } if ($arch eq 'source') { push @return, @@ -93,13 +112,26 @@ sub _member_constructor { ); } } + return @return; } -# Debbugs::Collection::Versions do not have a universe. +=head2 $versions->universe + +Unlike most collections, Debbugs::Collection::Version do not have a universe. + +=cut + sub universe { return $_[0]; } +=head2 $versions->source + +Returns a (potentially duplicated) list of source packages which are part of +this version collection + +=cut + sub source { my $self = shift; return $self->map(sub{$_->source});