line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package P5U::Command::cttail; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
19667
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
5
|
1
|
|
|
1
|
|
599
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
6
|
1
|
|
|
1
|
|
382
|
use P5U -command; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
|
|
|
|
|
|
$P5U::Command::cttail::AUTHORITY = 'cpan:TOBYINK'; |
10
|
|
|
|
|
|
|
$P5U::Command::cttail::VERSION = '0.001'; |
11
|
|
|
|
|
|
|
}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use constant TAIL_LOG => "http://metabase.cpantesters.org/tail/log.txt"; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use constant { |
16
|
|
|
|
|
|
|
abstract => q[grep through the last 1000 cpan testers reports], |
17
|
|
|
|
|
|
|
command_names => q[cttail], |
18
|
|
|
|
|
|
|
usage_desc => q[%c cttail %o], |
19
|
|
|
|
|
|
|
}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub opt_spec |
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
return ( |
24
|
|
|
|
|
|
|
[ "regexp|r=s" => "search entire line by regexp" ], |
25
|
|
|
|
|
|
|
[ "author|a=s" => "search for author cpan id" ], |
26
|
|
|
|
|
|
|
[ "dist|d=s" => "search for distribution name" ], |
27
|
|
|
|
|
|
|
[ "version|v=s" => "search for version number" ], |
28
|
|
|
|
|
|
|
[ "grade|g=s" => "search for grade" ], |
29
|
|
|
|
|
|
|
[ "reporter|t=s" => "search for reporter by regexp" ], |
30
|
|
|
|
|
|
|
[ "platform|p=s" => "search for platform by regexp" ], |
31
|
|
|
|
|
|
|
[ "format|F=s" => "Text::sprintfn-compatible output format" ], |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub execute |
36
|
|
|
|
|
|
|
{ |
37
|
|
|
|
|
|
|
require LWP::Simple; |
38
|
|
|
|
|
|
|
require Text::sprintfn; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my ($self, $opt, $args) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $format = $opt->format // |
43
|
|
|
|
|
|
|
q{%(grade)s: %(filename)s %(perlversion)s %(platform)s (%(reporter)s)}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my @log = split /\r?\n/, LWP::Simple::get(TAIL_LOG); |
46
|
|
|
|
|
|
|
for my $line (@log) |
47
|
|
|
|
|
|
|
{ |
48
|
|
|
|
|
|
|
my $data = $self->_parse_line($line); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
next if (defined $opt->regexp and $line !~ m/${\ $opt->regexp}/i); |
51
|
|
|
|
|
|
|
next if (defined $opt->author and lc $data->{author} ne lc $opt->author); |
52
|
|
|
|
|
|
|
next if (defined $opt->dist and lc $data->{dist} ne lc $opt->dist); |
53
|
|
|
|
|
|
|
next if (defined $opt->version and lc $data->{version} ne lc $opt->version); |
54
|
|
|
|
|
|
|
next if (defined $opt->grade and lc $data->{grade} ne lc $opt->grade); |
55
|
|
|
|
|
|
|
next if (defined $opt->reporter and $data->{reporter} !~ m/${\ $opt->reporter}/i); |
56
|
|
|
|
|
|
|
next if (defined $opt->platform and $data->{platform} !~ m/${\ $opt->platform}/i); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Text::sprintfn::printfn("$format\n", $data); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _parse_line |
63
|
|
|
|
|
|
|
{ |
64
|
|
|
|
|
|
|
my ($self, $line) = @_; |
65
|
|
|
|
|
|
|
chomp $line; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return unless $line =~ m{ |
68
|
|
|
|
|
|
|
^ |
69
|
|
|
|
|
|
|
\[(?P .+? )\] |
70
|
|
|
|
|
|
|
\s* |
71
|
|
|
|
|
|
|
\[(?P .+? )\] |
72
|
|
|
|
|
|
|
\s* |
73
|
|
|
|
|
|
|
\[(?P .+? )\] |
74
|
|
|
|
|
|
|
\s* |
75
|
|
|
|
|
|
|
\[(?P .+? )\] |
76
|
|
|
|
|
|
|
\s* |
77
|
|
|
|
|
|
|
\[(?P .+? )\] |
78
|
|
|
|
|
|
|
\s* |
79
|
|
|
|
|
|
|
\[(?P .+? )\] |
80
|
|
|
|
|
|
|
\s* |
81
|
|
|
|
|
|
|
\[(?P .+? )\] |
82
|
|
|
|
|
|
|
\s* |
83
|
|
|
|
|
|
|
\[(?P .+? )\] |
84
|
|
|
|
|
|
|
}x; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my %P = %-; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
%P = (%P, %-) if $P{filename}[0] =~ m{ |
89
|
|
|
|
|
|
|
^ |
90
|
|
|
|
|
|
|
(?P .+? ) |
91
|
|
|
|
|
|
|
\/ |
92
|
|
|
|
|
|
|
(?P .+? ) |
93
|
|
|
|
|
|
|
\- |
94
|
|
|
|
|
|
|
(?P [vV]?[0-9][0-9_\.]*(?:-TRIAL)? ) |
95
|
|
|
|
|
|
|
\. |
96
|
|
|
|
|
|
|
(?P tar\.gz | tar\.bz2? | tgz | tbz2? | zip ) |
97
|
|
|
|
|
|
|
$ |
98
|
|
|
|
|
|
|
}x; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
$P{$_} = $P{$_}[0] for grep ref($P{$_}), keys %P; |
101
|
|
|
|
|
|
|
$P{grade} = uc $P{grade}; |
102
|
|
|
|
|
|
|
return \%P; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |