line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Testers::WWW::Reports::Parser; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
126275
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
231
|
|
4
|
6
|
|
|
6
|
|
35
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
297
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
36
|
use vars qw($VERSION); |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
448
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.05'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
# Library Modules |
11
|
|
|
|
|
|
|
|
12
|
6
|
|
|
6
|
|
50
|
use Carp; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
4701
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# Variables |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $WEB = 'http://www.cpantesters.org/cpan/report/'; |
18
|
|
|
|
|
|
|
my @valid_fields = qw( id distribution dist distname version distversion perl |
19
|
|
|
|
|
|
|
state status grade action osname ostext osvers platform |
20
|
|
|
|
|
|
|
archname url csspatch cssperl guid ); |
21
|
|
|
|
|
|
|
my %valid_fields = map {$_ => 1} @valid_fields; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
24
|
|
|
|
|
|
|
# The Application Programming Interface |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
4
|
|
|
4
|
1
|
1913
|
my $class = shift; |
28
|
4
|
|
|
|
|
26
|
my %hash = @_; |
29
|
|
|
|
|
|
|
|
30
|
4
|
50
|
|
|
|
23
|
croak "No data format specified\n" unless($hash{format}); |
31
|
4
|
50
|
|
|
|
70
|
croak "Unknown data format specified\n" unless($hash{format} =~ /^(yaml|json)$/i); |
32
|
4
|
50
|
66
|
|
|
30
|
croak "Must specify a file or data block to parse\n" unless($hash{data} || $hash{file}); |
33
|
4
|
50
|
66
|
|
|
103
|
croak "Cannot access file [$hash{file}]\n" if(defined $hash{file} && ! -f $hash{file}); |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
|
|
32
|
my $self = { |
36
|
|
|
|
|
|
|
'format' => uc $hash{'format'}, |
37
|
|
|
|
|
|
|
'data' => $hash{'data'}, |
38
|
|
|
|
|
|
|
'file' => $hash{'file'}, |
39
|
|
|
|
|
|
|
'objects' => $hash{'objects'}, |
40
|
|
|
|
|
|
|
}; |
41
|
4
|
|
|
|
|
17
|
bless $self, $class; |
42
|
|
|
|
|
|
|
|
43
|
4
|
100
|
|
|
|
43
|
if($self->{objects}) { |
44
|
1
|
|
|
1
|
|
82
|
eval "use CPAN::Testers::WWW::Reports::Report"; |
|
1
|
|
|
|
|
2305
|
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
32
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
|
|
24
|
my $parser = 'CPAN::Testers::WWW::Reports::Parser::' . $self->{'format'}; |
48
|
4
|
|
|
1
|
|
943
|
eval "use $parser"; |
|
1
|
|
|
1
|
|
949
|
|
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
1
|
|
22
|
|
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
23
|
|
49
|
4
|
50
|
|
|
|
22
|
croak "Cannot access $self->{'format'} parser, have you installed the necessary support modules?\n" |
50
|
|
|
|
|
|
|
if($@); |
51
|
|
|
|
|
|
|
|
52
|
4
|
|
|
|
|
41
|
$self->{parser} = $parser->new(); |
53
|
4
|
|
|
|
|
27
|
$self->{parser}->register( file => $self->{file}, data => $self->{data} ); |
54
|
4
|
|
|
|
|
11
|
$self->{current} = {}; |
55
|
|
|
|
|
|
|
|
56
|
4
|
|
|
|
|
20
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub DESTROY { |
60
|
4
|
|
|
4
|
|
7911
|
my $self = shift; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub filter { |
64
|
13
|
|
|
13
|
1
|
9508
|
my $self = shift; |
65
|
|
|
|
|
|
|
|
66
|
13
|
100
|
|
|
|
56
|
if(@_) { |
67
|
9
|
100
|
|
|
|
78
|
$self->{all} = $_[0] =~ /^ALL$/i ? shift : 0; |
68
|
9
|
|
|
|
|
36
|
$self->{fields}{$_} = 1 for(grep {$valid_fields{$_}} @_); |
|
51
|
|
|
|
|
212
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# if no arguments, reset to default |
71
|
|
|
|
|
|
|
} else { |
72
|
4
|
|
|
|
|
12
|
$self->{all} = 1; |
73
|
4
|
|
|
|
|
17
|
$self->{fields} = {}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# full data set methods |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub reports { |
80
|
9
|
|
|
9
|
1
|
22814
|
my $self = shift; |
81
|
|
|
|
|
|
|
|
82
|
9
|
100
|
|
|
|
52
|
$self->filter(@_) if(@_); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
#use Data::Dumper; |
85
|
|
|
|
|
|
|
#print STDERR (Dumper($self->{fields})); |
86
|
|
|
|
|
|
|
|
87
|
9
|
|
|
|
|
58
|
my $data = $self->{parser}->raw_data(); |
88
|
9
|
100
|
|
|
|
109
|
return $data unless(defined $self->{fields}); |
89
|
|
|
|
|
|
|
|
90
|
6
|
|
|
6
|
|
39
|
no strict 'refs'; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
1707
|
|
91
|
|
|
|
|
|
|
|
92
|
6
|
|
|
|
|
22
|
for my $report (@$data) { |
93
|
3222
|
|
|
|
|
4347
|
$self->{current} = $report; |
94
|
3222
|
|
|
|
|
3412
|
for my $field (keys %{ $self->{fields} }) { |
|
3222
|
|
|
|
|
8508
|
|
95
|
|
|
|
|
|
|
#print STDERR "field=$field\n"; |
96
|
12888
|
|
|
|
|
14452
|
eval { $report->{$field} = $self->$field(); }; |
|
12888
|
|
|
|
|
28592
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
3222
|
100
|
|
|
|
12590
|
next if($self->{all}); |
100
|
|
|
|
|
|
|
|
101
|
1611
|
|
|
|
|
7200
|
for my $key (keys %$report) { |
102
|
28998
|
100
|
|
|
|
110588
|
delete $report->{$key} unless($self->{fields}{$key}); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
6
|
|
|
|
|
53
|
return $data; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# iterate through data set |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub report { |
113
|
545
|
|
|
545
|
1
|
3961
|
my $self = shift; |
114
|
|
|
|
|
|
|
|
115
|
545
|
100
|
|
|
|
1083
|
unless($self->{loaded}) { |
116
|
8
|
|
|
|
|
60
|
$self->{reports} = $self->{parser}->raw_data(); |
117
|
8
|
|
|
|
|
4255
|
$self->{loaded} = 1; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
545
|
100
|
|
|
|
540
|
return unless(scalar(@{ $self->{reports} })); |
|
545
|
|
|
|
|
1075
|
|
121
|
|
|
|
|
|
|
|
122
|
544
|
|
|
|
|
561
|
$self->{current} = shift @{ $self->{reports} }; |
|
544
|
|
|
|
|
914
|
|
123
|
544
|
|
|
|
|
1837
|
my %report = map {$_ => $self->{current}{$_}} keys %{$self->{current}}; |
|
8160
|
|
|
|
|
29133
|
|
|
544
|
|
|
|
|
2348
|
|
124
|
|
|
|
|
|
|
|
125
|
544
|
100
|
|
|
|
2184
|
if(scalar(keys %{ $self->{fields} })) { |
|
544
|
|
|
|
|
1528
|
|
126
|
6
|
|
|
6
|
|
35
|
no strict 'refs'; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
4780
|
|
127
|
|
|
|
|
|
|
|
128
|
3
|
|
|
|
|
6
|
for my $field (keys %{ $self->{fields} }) { |
|
3
|
|
|
|
|
18
|
|
129
|
27
|
|
|
|
|
32
|
eval { $report{$field} = $self->$field(); }; |
|
27
|
|
|
|
|
91
|
|
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
3
|
100
|
|
|
|
16
|
unless($self->{all}) { |
133
|
2
|
|
|
|
|
11
|
for my $key (keys %report) { |
134
|
38
|
100
|
|
|
|
84
|
delete $report{$key} unless($self->{fields}{$key}); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
544
|
100
|
|
|
|
1035
|
if($self->{objects}) { |
140
|
1
|
|
|
|
|
17
|
my $rep = CPAN::Testers::WWW::Reports::Report->new(\%report); |
141
|
1
|
|
|
|
|
7
|
return $rep; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
543
|
|
|
|
|
1273
|
return \%report; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub reload { |
148
|
4
|
|
|
4
|
1
|
8692
|
my $self = shift; |
149
|
4
|
|
|
|
|
13
|
$self->{loaded} = 0; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# transpose legacy field names to current field names |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
0
|
1
|
0
|
sub guid { my $self = shift; return $self->{current}->{guid} } |
|
0
|
|
|
|
|
0
|
|
156
|
2
|
|
|
2
|
1
|
10
|
sub id { my $self = shift; return $self->{current}->{id} } |
|
2
|
|
|
|
|
12
|
|
157
|
2
|
|
|
2
|
1
|
891
|
sub distribution { my $self = shift; return $self->{current}->{distribution} } |
|
2
|
|
|
|
|
7
|
|
158
|
2
|
|
|
2
|
1
|
449
|
sub dist { my $self = shift; return $self->{current}->{distribution} } |
|
2
|
|
|
|
|
9
|
|
159
|
3226
|
|
|
3226
|
1
|
6965
|
sub distname { my $self = shift; return $self->{current}->{distribution} } |
|
3226
|
|
|
|
|
14369
|
|
160
|
3226
|
|
|
3226
|
1
|
17515
|
sub version { my $self = shift; return $self->{current}->{version} } |
|
3226
|
|
|
|
|
11957
|
|
161
|
2
|
|
|
2
|
1
|
537
|
sub distversion { my $self = shift; return $self->{current}->{distversion} } |
|
2
|
|
|
|
|
12
|
|
162
|
2
|
|
|
2
|
1
|
708
|
sub perl { my $self = shift; return $self->{current}->{perl} } |
|
2
|
|
|
|
|
188
|
|
163
|
|
|
|
|
|
|
|
164
|
2
|
|
|
2
|
1
|
512
|
sub state { my $self = shift; return $self->{current}->{state} } |
|
2
|
|
|
|
|
14
|
|
165
|
2
|
|
|
2
|
1
|
496
|
sub status { my $self = shift; return $self->{current}->{status} } |
|
2
|
|
|
|
|
12
|
|
166
|
3226
|
|
|
3226
|
1
|
4421
|
sub grade { my $self = shift; return $self->{current}->{status} } |
|
3226
|
|
|
|
|
33660
|
|
167
|
2
|
|
|
2
|
1
|
517
|
sub action { my $self = shift; return $self->{current}->{status} } |
|
2
|
|
|
|
|
10
|
|
168
|
|
|
|
|
|
|
|
169
|
2
|
|
|
2
|
1
|
487
|
sub osname { my $self = shift; return $self->{current}->{osname} } |
|
2
|
|
|
|
|
11
|
|
170
|
2
|
|
|
2
|
1
|
480
|
sub ostext { my $self = shift; return $self->{current}->{ostext} } |
|
2
|
|
|
|
|
10
|
|
171
|
2
|
|
|
2
|
1
|
422
|
sub osvers { my $self = shift; return $self->{current}->{osvers} } |
|
2
|
|
|
|
|
10
|
|
172
|
2
|
|
|
2
|
1
|
1115
|
sub platform { my $self = shift; return $self->{current}->{platform} } |
|
2
|
|
|
|
|
9
|
|
173
|
2
|
|
|
2
|
1
|
499
|
sub archname { my $self = shift; return $self->{current}->{platform} } |
|
2
|
|
|
|
|
11
|
|
174
|
|
|
|
|
|
|
|
175
|
3226
|
|
33
|
3226
|
1
|
5682
|
sub url { my $self = shift; return $WEB . ($self->{current}->{guid} || $self->{current}->{id}) } |
|
3226
|
|
|
|
|
15872
|
|
176
|
|
|
|
|
|
|
|
177
|
2
|
|
|
2
|
1
|
16609
|
sub csspatch { my $self = shift; return $self->{current}->{csspatch} } |
|
2
|
|
|
|
|
15
|
|
178
|
2
|
|
|
2
|
1
|
581
|
sub cssperl { my $self = shift; return $self->{current}->{cssperl} } |
|
2
|
|
|
|
|
10
|
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
q{ another hope, another dream, another truth ... installed by the machine }; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
__END__ |