]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Package.pm
add source_names and maintainers to Debbugs:;Package
[debbugs.git] / Debbugs / Package.pm
index 2ca0147b01ff88097a083c1b27d5c797d0c24072..68e0447c9004e010bb2dbdea3d81e1a720afabd8 100644 (file)
@@ -33,10 +33,35 @@ use Debbugs::Version::Binary;
 
 extends 'Debbugs::OOBase';
 
+=head2 name
+
+Name of the Package
+
+=head2 qualified_name
+
+name if binary, name prefixed with C<src:> if source
+
+=cut
+
 has name => (is => 'ro', isa => 'Str',
             required => 1,
            );
 
+sub qualified_name {
+    my $self = shift;
+    return
+       # src: if source, nothing if binary
+       ($self->_type eq 'source' ? 'src:':'') .
+       $self->name;
+}
+
+
+=head2 type
+
+Type of the package; either C<binary> or C<source>
+
+=cut
+
 has type => (is => 'bare', isa => 'Str',
             lazy => 1,
             builder => '_build_type',
@@ -52,13 +77,11 @@ sub _build_type {
     }
 }
 
-sub qualified_name {
-    my $self = shift;
-    return
-       # src: if source, nothing if binary
-       ($self->_type eq 'source' ? 'src:':'') .
-       $self->name;
-}
+=head2 url
+
+url to the package
+
+=cut
 
 sub url {
     my $self = shift;
@@ -85,6 +108,16 @@ around BUILDARGS => sub {
     return $class->$orig(%args);
 };
 
+=head2 is_source
+
+true if the package is a source package
+
+=head2 is_binary
+
+true if the package is a binary package
+
+=cut
+
 sub is_source {
     return $_[0]->_type eq 'source'
 }
@@ -93,6 +126,10 @@ sub is_binary {
     return $_[0]->_type eq 'binary'
 }
 
+=head2 valid -- true if the package has any valid versions
+
+=cut
+
 has valid => (is => 'ro', isa => 'Bool',
              lazy => 1,
              builder => '_build_valid',
@@ -480,13 +517,41 @@ has 'sources' => (is => 'ro',
 
 sub _build_sources {
     my $self = shift;
+    return $self->package_collection->limit($self->source_names);
+}
+
+sub source_names {
+    my $self = shift;
+
     if ($self->is_source) {
-       return $self->package_collection->limit($self);
+        return $self->name
     }
-    # OK, walk through the valid_versions for this package
-    my @sources =
-       uniq map {'src:'.$_->{src_pkg_name}} $self->_valid_versioninfo;
-    return $self->package_collection->limit(@sources);
+    return uniq map {'src:'.$_->{src_pkg}} $self->_valid_version_info;
+}
+
+=head2 maintainers 
+
+L<Debbugs::Collection::Correspondent> of the maintainer(s) of the current package
+
+=cut
+
+has maintainers => (is => 'ro',
+                    isa => 'Debbugs::Collection::Correspondent',
+                    lazy => 1,
+                    builder => '_build_maintainers',
+                    predicate => '_has_maintainers',
+                   );
+
+sub _build_maintainers {
+    my $self = shift;
+    my @maintainers;
+    for my $v ($self->_valid_version_info) {
+        next unless length($v->{suite_name}) and length($v->{maintainer});
+        push @maintainers,$v->{maintainer};
+    }
+    @maintainers =
+        uniq @maintainers;
+    return $self->correspondent_collection->limit(@maintainers);
 }
 
 has 'versions' => (is => 'bare',
@@ -607,6 +672,12 @@ sub _create_version {
     $self->_set_version(@versions);
 }
 
+=head2 package_collection
+
+L<Debbugs::Collection::Package> to get additional packages required
+
+=cut
+
 # gets used to retrieve packages
 has 'package_collection' => (is => 'ro',
                             isa => 'Debbugs::Collection::Package',
@@ -619,6 +690,23 @@ sub _build_package_collection {
     return Debbugs::Collection::Package->new($self->schema_argument)
 }
 
+=head2 correspondent_collection
+
+L<Debbugs::Collection::Correspondent> to get additional maintainers required
+
+=cut
+
+has 'correspondent_collection' => (is => 'ro',
+                                   isa => 'Debbugs::Collection::Correspondent',
+                                   builder => '_build_correspondent_collection',
+                                   lazy => 1,
+                                  );
+
+sub _build_correspondent_collection {
+    my $self = shift;
+    return Debbugs::Collection::Correspondent->new($self->schema_argument)
+}
+
 sub CARP_TRACE {
     my $self = shift;
     return 'Debbugs::Package={package='.$self->qualified_name.'}';