line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PAUSE::Permissions::ModuleIterator; |
2
|
|
|
|
|
|
|
$PAUSE::Permissions::ModuleIterator::VERSION = '0.14'; |
3
|
6
|
|
|
6
|
|
22
|
use strict; |
|
6
|
|
|
|
|
45
|
|
|
6
|
|
|
|
|
214
|
|
4
|
6
|
|
|
6
|
|
18
|
use warnings; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
126
|
|
5
|
6
|
|
|
6
|
|
58
|
use 5.10.0; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
181
|
|
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
18
|
use Moo; |
|
6
|
|
|
|
|
4
|
|
|
6
|
|
|
|
|
27
|
|
8
|
6
|
|
|
6
|
|
1306
|
use PAUSE::Permissions::Module; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
79
|
|
9
|
6
|
|
|
6
|
|
2562
|
use autodie; |
|
6
|
|
|
|
|
67478
|
|
|
6
|
|
|
|
|
26
|
|
10
|
6
|
|
|
6
|
|
24586
|
use feature 'state'; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
2914
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'permissions' => |
13
|
|
|
|
|
|
|
( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
# isa => 'PAUSE::Permissions', |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has _fh => (is => 'rw'); |
19
|
|
|
|
|
|
|
has _cached_line => (is => 'rw', clearer => '_clear_cached_line'); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub next_module |
22
|
|
|
|
|
|
|
{ |
23
|
30
|
|
|
30
|
0
|
1029
|
my $self = shift; |
24
|
30
|
|
|
|
|
28
|
my $line; |
25
|
|
|
|
|
|
|
my $current_module; |
26
|
0
|
|
|
|
|
0
|
my $fh; |
27
|
|
|
|
|
|
|
|
28
|
30
|
100
|
|
|
|
86
|
if (not defined $self->_fh) { |
29
|
5
|
|
|
|
|
24
|
$fh = $self->permissions->open_file(); |
30
|
5
|
|
|
|
|
7
|
my $inheader = 1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Skip the header block at the top of the file |
33
|
5
|
|
|
|
|
74
|
while (<$fh>) { |
34
|
15
|
100
|
|
|
|
44
|
last if /^$/; |
35
|
|
|
|
|
|
|
} |
36
|
5
|
|
|
|
|
15
|
$self->_fh($fh); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
25
|
|
|
|
|
27
|
$fh = $self->_fh; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
30
|
|
|
|
|
26
|
my $perms = {}; |
43
|
30
|
|
|
|
|
23
|
while (1) { |
44
|
90
|
100
|
|
|
|
111
|
if (defined $self->_cached_line) { |
45
|
20
|
|
|
|
|
25
|
$line = $self->_cached_line; |
46
|
20
|
|
|
|
|
213
|
$self->_clear_cached_line(); |
47
|
|
|
|
|
|
|
} else { |
48
|
70
|
|
|
|
|
105
|
$line = <$fh>; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
90
|
100
|
|
|
|
1167
|
if (defined($line)) { |
|
|
100
|
|
|
|
|
|
52
|
80
|
|
|
|
|
148
|
$line =~ s/[\r\n]+$//; |
53
|
80
|
|
|
|
|
115
|
my ($module, $user, $permission) = split(/,/, $line); |
54
|
80
|
|
|
|
|
71
|
$user = uc($user); |
55
|
80
|
100
|
100
|
|
|
183
|
if (defined($current_module) && $module ne $current_module) { |
56
|
20
|
|
|
|
|
27
|
$self->_cached_line($line); |
57
|
20
|
|
|
|
|
21
|
my $module_name = $current_module; |
58
|
20
|
|
|
|
|
12
|
$current_module = undef; |
59
|
20
|
|
|
|
|
35
|
return $self->_new_module($module_name, $perms); |
60
|
|
|
|
|
|
|
} |
61
|
60
|
|
|
|
|
46
|
$current_module = $module; |
62
|
60
|
|
|
|
|
32
|
push(@{ $perms->{ $permission } }, $user); |
|
60
|
|
|
|
|
99
|
|
63
|
|
|
|
|
|
|
} elsif (defined $current_module) { |
64
|
5
|
|
|
|
|
11
|
return $self->_new_module($current_module, $perms); |
65
|
|
|
|
|
|
|
} else { |
66
|
5
|
|
|
|
|
16
|
return undef; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _new_module |
73
|
|
|
|
|
|
|
{ |
74
|
25
|
|
|
25
|
|
21
|
my $self = shift; |
75
|
25
|
|
|
|
|
21
|
my $module_name = shift; |
76
|
25
|
|
|
|
|
15
|
my $perms = shift; |
77
|
25
|
|
|
|
|
30
|
my @args = (name => $module_name); |
78
|
|
|
|
|
|
|
|
79
|
25
|
100
|
|
|
|
46
|
push(@args, m => $perms->{m}->[0]) if exists($perms->{m}); |
80
|
25
|
100
|
|
|
|
42
|
push(@args, f => $perms->{f}->[0]) if exists($perms->{f}); |
81
|
25
|
100
|
|
|
|
44
|
push(@args, c => $perms->{c}) if exists($perms->{c}); |
82
|
|
|
|
|
|
|
|
83
|
25
|
|
|
|
|
328
|
return PAUSE::Permissions::Module->new(@args); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |