Baseline - Launch of backpan.org
[catagits/BackPAN-Web.git] / lib / BackPAN / Index / Dist.pm
1 package BackPAN::Index::Dist;
2
3 use strict;
4 use warnings;
5
6 use CLASS;
7 use BackPAN::Index::Role::AsHash;
8
9 use overload
10   q[""]         => sub { $_[0]->name },
11   fallback      => 1;
12
13 sub data_methods {
14     return qw(
15         name num_releases
16         first_release  first_date  first_author
17         latest_release latest_date latest_author
18     );
19 }
20
21 sub authors {
22     my $self = shift;
23
24     return $self->releases->search(undef, { distinct => 1 })->get_column("cpanid")->all;
25 }
26
27 1;
28
29 __END__
30
31 =head1 NAME
32
33 BackPAN::Index::Dist - Representing a distribution on BackPAN
34
35 =head1 SYNOPSIS
36
37 Use through BackPAN::Index.
38
39 =head1 DESCRIPTION
40
41 An object representing a distribution on BackPAN.  A distribution is
42 made up of releases.
43
44 =head2 releases
45
46     my $releases = $dist->releases;
47
48 A ResultSet of this distribution's releases.
49
50 =head2 name
51
52     my $dist_name = $dist->name;
53
54 Name of the distribution.
55
56 =head2 authors
57
58     my @authors = $dist->authors;
59
60 Return the CPANIDs which made releases of this $dist, in no particular order.
61
62 =head2 num_releases
63
64     my $num_releases = $dist->num_releases;
65
66 Returns the number of releases this distribution has.
67
68 =head2 first_release
69
70 =head2 latest_release
71
72     my $release = $dist->first_release;
73
74 Returns the first or latest release of this distribution as a BackPAN::Index::Release.
75
76 =head2 first_date
77
78 =head2 latest_date
79
80     my $release = $dist->first_date;
81
82 Returns the date of the first or latest release of this distribution.
83
84 =head2 first_author
85
86 =head2 latest_author
87
88     my $cpanid = $dist->first_author;
89
90 Returns the CPANID of the author of the first or latest release.
91
92 =head2 as_hash
93
94     my $data = $dist->as_hash;
95
96 Returns a hash ref containing the data inside C<$dist>.
97
98
99 =head1 SEE ALSO
100
101 L<BackPAN::Index>
102
103 =cut
104
105 1;