line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Repository::Perms; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:GETTY'; |
3
|
|
|
|
|
|
|
# ABSTRACT: 06perms |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.010'; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1378
|
use Moo; |
|
3
|
|
|
|
|
14968
|
|
|
3
|
|
|
|
|
19
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with qw( |
10
|
|
|
|
|
|
|
CPAN::Repository::Role::File |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
2959
|
use Dist::Data; |
|
3
|
|
|
|
|
435530
|
|
|
3
|
|
|
|
|
102
|
|
14
|
3
|
|
|
3
|
|
20
|
use File::Spec::Functions ':ALL'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
642
|
|
15
|
3
|
|
|
3
|
|
17
|
use IO::File; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
487
|
|
16
|
3
|
|
|
3
|
|
854
|
use DateTime::Format::RFC3339; |
|
3
|
|
|
|
|
1086
|
|
|
3
|
|
|
|
|
78
|
|
17
|
3
|
|
|
3
|
|
16
|
use DateTime::Format::Epoch::Unix; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
3083
|
|
18
|
|
|
|
|
|
|
|
19
|
7
|
|
|
7
|
0
|
170
|
sub file_parts { 'modules', '06perms.txt' } |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our @perm_perms = qw( m f c ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has perms => ( |
24
|
|
|
|
|
|
|
is => 'rw', |
25
|
|
|
|
|
|
|
lazy => 1, |
26
|
|
|
|
|
|
|
builder => '_build_perms', |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _build_perms { |
30
|
2
|
|
|
2
|
|
895
|
my ( $self ) = @_; |
31
|
2
|
50
|
|
|
|
15
|
return {} unless $self->exist; |
32
|
0
|
|
|
|
|
0
|
my @lines = $self->get_file_lines; |
33
|
0
|
|
|
|
|
0
|
my %perms; |
34
|
0
|
|
|
|
|
0
|
for (@lines) { |
35
|
0
|
|
|
|
|
0
|
chomp($_); |
36
|
0
|
0
|
|
|
|
0
|
next if ($_ =~ /[^:]:[ \t]/); |
37
|
0
|
0
|
|
|
|
0
|
next if ($_ =~ /^ +/); |
38
|
0
|
0
|
|
|
|
0
|
next unless $_; |
39
|
0
|
|
|
|
|
0
|
my @perm_parts = split(',',$_); |
40
|
0
|
0
|
|
|
|
0
|
if (@perm_parts == 3) { |
41
|
0
|
|
|
|
|
0
|
my $module = shift @perm_parts; |
42
|
0
|
|
|
|
|
0
|
my $userid = shift @perm_parts; |
43
|
0
|
|
|
|
|
0
|
my $perm = shift @perm_parts; |
44
|
0
|
0
|
|
|
|
0
|
$perms{$module} = {} unless defined $perms{$module}; |
45
|
0
|
0
|
|
|
|
0
|
warn "already found entry for ".$userid." on ".$module if defined $perms{$module}->{$userid}; |
46
|
0
|
|
|
|
|
0
|
$perms{$module}->{$userid} = $perm; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
0
|
return \%perms; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has written_by => ( |
53
|
|
|
|
|
|
|
is => 'ro', |
54
|
|
|
|
|
|
|
required => 1, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub perms_linecount { |
58
|
2
|
|
|
2
|
0
|
10
|
my ( $self ) = @_; |
59
|
2
|
|
|
|
|
4
|
my $i = 0; |
60
|
2
|
|
|
|
|
4
|
for (keys %{$self->perms}) { |
|
2
|
|
|
|
|
27
|
|
61
|
3
|
|
|
|
|
10
|
for my $u (keys %{$self->perms->{$_}}) { |
|
3
|
|
|
|
|
58
|
|
62
|
3
|
|
|
|
|
25
|
$i++; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
2
|
|
|
|
|
10
|
return $i; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub set_perms { |
69
|
3
|
|
|
3
|
0
|
1529
|
my ( $self, $module, $userid, $perm ) = @_; |
70
|
3
|
50
|
|
|
|
6
|
die "unknown perm ".$perm unless grep { $_ eq $perm } @perm_perms; |
|
9
|
|
|
|
|
28
|
|
71
|
3
|
50
|
|
|
|
45
|
$self->perms->{$module} = {} unless defined $self->perms->{$module}; |
72
|
3
|
|
|
|
|
137
|
$self->perms->{$module}->{$userid} = $perm; |
73
|
3
|
|
|
|
|
23
|
return $self; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub get_perms { |
77
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $module ) = @_; |
78
|
|
|
|
|
|
|
return defined $self->perms->{$module} |
79
|
0
|
0
|
|
|
|
0
|
? $self->perms->{$module} |
80
|
|
|
|
|
|
|
: {} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub get_perms_by_userid { |
84
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $userid ) = @_; |
85
|
0
|
|
|
|
|
0
|
my %perms_by_userid; |
86
|
0
|
|
|
|
|
0
|
for (keys %{$self->perms}) { |
|
0
|
|
|
|
|
0
|
|
87
|
0
|
0
|
|
|
|
0
|
if (defined $self->perms->{$_}->{$userid}) { |
88
|
0
|
|
|
|
|
0
|
$perms_by_userid{$_} = $self->perms->{$_}->{$userid}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
0
|
|
|
|
|
0
|
return \%perms_by_userid; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# File: 06perms.txt |
95
|
|
|
|
|
|
|
# Description: CSV file of upload permission to the CPAN per namespace |
96
|
|
|
|
|
|
|
# best-permission is one of "m" for "modulelist", "f" for |
97
|
|
|
|
|
|
|
# "first-come", "c" for "co-maint" |
98
|
|
|
|
|
|
|
# Columns: package,userid,best-permission |
99
|
|
|
|
|
|
|
# Line-Count: 215301 |
100
|
|
|
|
|
|
|
# Written-By: PAUSE version 1.14 |
101
|
|
|
|
|
|
|
# Date: Fri, 06 Jul 2012 20:23:21 GMT |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub generate_content { |
104
|
2
|
|
|
2
|
0
|
11
|
my ( $self ) = @_; |
105
|
2
|
|
|
|
|
8
|
my @file_parts = $self->file_parts; |
106
|
2
|
|
|
|
|
5
|
my $content = ""; |
107
|
2
|
|
|
|
|
9
|
$content .= $self->generate_header_line('File:',(pop @file_parts)); |
108
|
2
|
|
|
|
|
8
|
$content .= $self->generate_header_line('Description:','Description: CSV file of upload permission to the CPAN per namespace'); |
109
|
2
|
|
|
|
|
6
|
$content .= ' best-permission is one of "m" for "modulelist", "f" for'."\n"; |
110
|
2
|
|
|
|
|
4
|
$content .= ' "first-come", "c" for "co-maint"'."\n"; |
111
|
2
|
|
|
|
|
7
|
$content .= $self->generate_header_line('Columns:','package, userid, best-permission'); |
112
|
2
|
|
|
|
|
7
|
$content .= $self->generate_header_line('Intended-For:','Automated fetch routines, namespace documentation.'); |
113
|
2
|
|
|
|
|
10
|
$content .= $self->generate_header_line('Written-By:',$self->written_by); |
114
|
2
|
|
|
|
|
10
|
$content .= $self->generate_header_line('Line-Count:',$self->perms_linecount); |
115
|
2
|
|
|
|
|
20
|
$content .= $self->generate_header_line('Date:',DateTime->now->strftime('%a, %e %b %y %T %Z')); |
116
|
2
|
|
|
|
|
16
|
$content .= "\n"; |
117
|
|
|
|
|
|
|
|
118
|
2
|
|
|
|
|
5
|
my @perms; |
119
|
2
|
|
|
|
|
5
|
for (sort { $a cmp $b } keys %{$self->perms}) { |
|
3
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
52
|
|
120
|
3
|
|
|
|
|
19
|
for my $u (sort { $a cmp $b } keys %{$self->perms->{$_}}) { |
|
0
|
|
|
|
|
0
|
|
|
3
|
|
|
|
|
128
|
|
121
|
3
|
|
|
|
|
77
|
push @perms, join(",",$_,$u,$self->perms->{$_}->{$u}); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
2
|
|
|
|
|
22
|
$content .= join "\n", @perms; |
125
|
2
|
|
|
|
|
10
|
return $content; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub generate_header_line { |
129
|
14
|
|
|
14
|
0
|
949
|
my ( $self, $key, $value ) = @_; |
130
|
14
|
|
|
|
|
53
|
return sprintf("%-13s %s\n",$key,$value); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
__END__ |