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