File Coverage

blib/lib/PAUSE/Permissions/Module.pm
Criterion Covered Total %
statement 22 22 100.0
branch 10 10 100.0
condition 9 9 100.0
subroutine 6 6 100.0
pod 5 5 100.0
total 52 52 100.0


line stmt bran cond sub pod time code
1             package PAUSE::Permissions::Module;
2             $PAUSE::Permissions::Module::VERSION = '0.14';
3 6     6   20 use Moo;
  6         7  
  6         21  
4              
5             # TODO: I had isa when I was using Moose, need to put those back
6              
7             has 'name' => (is => 'ro');
8              
9             # has 'm' => (is => 'ro', isa => 'Str');
10             has 'm' => (is => 'ro');
11              
12             # has 'f' => (is => 'ro', isa => 'Str');
13             has 'f' => (is => 'ro');
14              
15             # has 'c' => (is => 'ro', isa => 'ArrayRef[Str]');
16             has 'c' => (is => 'ro');
17              
18             sub owner
19             {
20 52     52 1 2923 my $self = shift;
21              
22 52   100     287 return $self->m || $self->f || undef;
23             }
24              
25             sub registered_maintainer
26             {
27 6     6 1 1456 my $self = shift;
28 6   100     32 return $self->m || undef;
29             }
30              
31             sub first_come
32             {
33 6     6 1 1515 my $self = shift;
34 6   100     33 return $self->f || undef;
35             }
36              
37             sub co_maintainers
38             {
39 16     16 1 1478 my $self = shift;
40 16         12 my @comaints;
41              
42 16 100 100     64 push(@comaints, $self->f) if defined($self->m) && defined($self->f);
43 16 100       33 push(@comaints, @{ $self->c }) if defined($self->c);
  13         18  
44              
45 16         87 return sort @comaints;
46             }
47              
48             sub all_maintainers
49             {
50 31     31 1 1485 my $self = shift;
51 31         61 my @all;
52              
53 31 100       79 push(@all, $self->m) if defined($self->m);
54 31 100       52 push(@all, $self->f) if defined($self->f);
55 31 100       48 push(@all, @{ $self->c }) if defined($self->c);
  25         31  
56              
57 31         91 return sort @all;
58             }
59              
60             1;
61              
62             =head1 NAME
63              
64             PAUSE::Permissions::Module - PAUSE permissions for one module (from 06perms.txt)
65              
66             =head1 SYNOPSIS
67              
68             use PAUSE::Permissions::Module;
69              
70             my %options =
71             (
72             name => 'HTTP::Client',
73             m => 'LINC',
74             f => 'P5P,
75             c => ['NEILB'],
76             );
77            
78             my $mp = PAUSE::Permissions::Module->new( %options );
79            
80             print "owner = ", $mp->owner, "\n";
81              
82             =head1 DESCRIPTION
83              
84             PAUSE::Permissions::Module is a data class, an instance of which is returned
85             by the C method in L.
86             It's not expected that you'll instantiate this module yourself,
87             but you're probably reading this to find out what methods are supported.
88              
89             =head1 METHODS
90              
91             To understand the three levels of PAUSE permissions, see L.
92              
93             =head2 owner
94              
95             Returns a single PAUSE id, or C.
96              
97             =head2 co_maintainers
98              
99             Returns a list of PAUSE ids,
100             which will be empty if the module doesn't have any co-maintainers.
101             The list will be sorted alphabetically.
102              
103             B if a module has both an 'm' permission and an 'f' permission,
104             then the user with the 'f' permission will included in the list returned by C,
105             because PAUSE treats them as a co-maintainer.
106              
107             =head2 registered_maintainer
108              
109             Returns the PAUSE id of the registered maintainer of the module
110             (the 'm' permission),
111             or C if there isn't one defined for the module.
112              
113             =head2 first_come
114              
115             Returns the PAUSE id of the 'first uploader' for the module
116             (the 'f' permission),
117             or C if there isn't one defined for the module.
118              
119             =head2 all_maintainers
120              
121             Returns the PAUSE id of all users who have permissions for this module,
122             in alphabetical order.
123              
124             =head1 SEE ALSO
125              
126             L
127              
128             =head1 AUTHOR
129              
130             Neil Bowers Eneilb@cpan.orgE
131              
132             Thanks to Andreas KEnig, for patiently answering many questions
133             on how this stuff all works.
134              
135             =head1 COPYRIGHT AND LICENSE
136              
137             This software is copyright (c) 2012-2013 by Neil Bowers .
138              
139             This is free software; you can redistribute it and/or modify it under
140             the same terms as the Perl 5 programming language system itself.
141              
142             =cut
143