File Coverage

blib/lib/PAUSE/Permissions/EntryIterator.pm
Criterion Covered Total %
statement 31 31 100.0
branch 6 6 100.0
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 44 45 97.7


line stmt bran cond sub pod time code
1             package PAUSE::Permissions::EntryIterator;
2             $PAUSE::Permissions::EntryIterator::VERSION = '0.16';
3 6     6   20 use strict;
  6         5  
  6         138  
4 6     6   15 use warnings;
  6         6  
  6         121  
5              
6 6     6   16 use Moo;
  6         5  
  6         20  
7 6     6   3257 use PAUSE::Permissions::Entry;
  6         8  
  6         125  
8 6     6   25 use autodie;
  6         6  
  6         20  
9 6     6   16319 use feature 'state';
  6         13  
  6         1296  
10              
11             has 'permissions' =>
12             (
13             is => 'ro',
14             # isa => 'PAUSE::Permissions',
15             );
16              
17             sub next
18             {
19 13     13 0 1659 my $self = shift;
20 13         10 state $fh;
21              
22 13 100       20 if (not defined $fh) {
23 1         7 open($fh, '<', $self->permissions->path);
24 1         1325 my $inheader = 1;
25              
26             # Skip the header block at the top of the file
27 1         11 while (<$fh>) {
28 3 100       10 last if /^$/;
29             }
30             }
31              
32 13         20 my $line = <$fh>;
33              
34 13 100       14 if (defined($line)) {
35 12         8 chomp($line);
36 12         22 my ($module, $user, $permission) = split(/,/, $line);
37 12         148 return PAUSE::Permissions::Entry->new(module => $module, user => $user, permission => $permission);
38             } else {
39 1         2 return undef;
40             }
41             }
42              
43             1;