Labyrinth/Plugin/Metabase/Parser.pm

filter: Statementstmt 44.3% 39 / 88 Branchbran 0.0% 0 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 12 / 15 Podpod 100% 1 / 1 totaltotal 41.2% 52 / 126 CC 12 SCAR 32.6
CC
12
Cov
35%
_parse_nntp_report
72.0
View
20.0
_parse_guid_report
6.0
CRAP 26.2
« Labyrinth/Plugin/CPAN/Authors.pm ↑ Summary Labyrinth/Plugin/CPAN/Monitor.pm »
1 package Labyrinth::Plugin::Metabase::Parser;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 $VERSION = '3.59';
8  
9 =head1 NAME
10  
11 Labyrinth::Plugin::Metabase::Parser - Plugin to parse Metabase Report pages.
12  
13 =cut
14  
15 #----------------------------------------------------------------------------
16 # Libraries
17  
18 4 ▶use base qw(Labyrinth::Plugin::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 4 ▶use Labyrinth::Audit;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 4 ▶use Labyrinth::DBUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 4 ▶use Labyrinth::DTUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 4 ▶use Labyrinth::Plugin::CPAN;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 4 ▶use Labyrinth::Variables;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 4 ▶use Labyrinth::Writer;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 4 ▶use CPAN::Testers::Common::Article;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 4 ▶use Data::FlexSerializer;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 #----------------------------------------------------------------------------
31 # Variables
32  
33 4 my $serializer = Data::FlexSerializer->new( detect_compression => 1 );
34  
35 #----------------------------------------------------------------------------
36 # Public Interface Functions
37  
38 =head1 METHODS
39  
40 =head2 Public Interface Methods
41  
42 =over 4
43  
44 =item View
45  
46 View a specific report.
47  
48 =back
49  
50 =cut
51  
52 sub View {
53 0 ▶ if($cgiparams{id} =~ /^\d+$/) {
Subroutine View: not called CC=4 SCAR=30.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Metabase::Parser::cgiparams{'id'} =~ /^\d+$/) { } 0 0 0
elsif ($Labyrinth::Plugin::Metabase::Parser::cgiparams{'id'} =~ /^[-\w]+$/) { } 0 0 0
54 0 _parse_nntp_report();
55 } elsif($cgiparams{id} =~ /^[-\w]+$/) {
56 0 _parse_guid_report();
57 } else {
58 0 $tvars{errcode} = 'NEXT';
59 0 $tvars{command} = 'cpan-distunk';
60 }
61  
62 0 ▶ if($cgiparams{raw}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Metabase::Parser::cgiparams{"raw"}) 0 0 0
63 0 $tvars{article}{raw} = $cgiparams{raw};
64 0 $tvars{realm} = 'popup';
65 }
66 }
67  
68 #----------------------------------------------------------------------------
69 # Private Interface Functions
70  
71 sub _parse_nntp_report {
72 0 ▶ my @rows = $dbi->GetQuery('hash','GetArticle',$cgiparams{id});
Subroutine _parse_nntp_report: not called CC=8 SCAR=42.8
73 0 ▶ unless(@rows) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@rows) 0 0 0
74 0 $tvars{article}{id} = $cgiparams{id};
75 0 return;
76 }
77  
78 0 $tvars{article} = $rows[0];
79 0 ($tvars{article}{head},$tvars{article}{body}) = split(/\n\n/,$rows[0]->{article},2);
80  
81 0 my $object = CPAN::Testers::Common::Article->new($rows[0]->{article});
82 0 ▶ return unless($object);
Branch: 1 branch
BranchTrueFalseTotal
unless $object 0 0 0
83  
84 0 $tvars{article}{body} = $object->body;
85 0 $tvars{article}{subject} = $object->subject;
86 0 $tvars{article}{from} = $object->from;
87 0 $tvars{article}{from} =~ s/\@.*//;
88 0 $tvars{article}{post} = $object->postdate;
89 0 $tvars{article}{date} = $object->date;
90  
91 0 ▶ return if($tvars{article}{subject} =~ /Re:/i);
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Metabase::Parser::tvars{"article"}{"subject"} =~ /Re:/i 0 0 0
92 0 ▶ return unless($tvars{article}{subject} =~ /(CPAN|FAIL|PASS|NA|UNKNOWN)\s+/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $Labyrinth::Plugin::Metabase::Parser::tvars{"article"}{"subject"} =~ /(CPAN|FAIL|PASS|NA|UNKNOWN)\s+/i 0 0 0
93  
94 0 my $state = lc $1;
95  
96 0 ▶ if($state eq 'cpan') {
Branch: 1 branch
BranchTrueFalseTotal
if ($state eq 'cpan') { } 0 0 0
97 0 ▶ if($object->parse_upload()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($object->parse_upload) 0 0 0
98 0 $tvars{article}{dist} = $object->distribution;
99 0 $tvars{article}{version} = $object->version;
100 0 $tvars{article}{author} = $object->author;
101 0 $tvars{article}{letter} = substr($tvars{article}{dist},0,1);
102 }
103 } else {
104 0 ▶ if($object->parse_report()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($object->parse_report) 0 0 0
105 0 $tvars{article}{dist} = $object->distribution;
106 0 $tvars{article}{version} = $object->version;
107 0 $tvars{article}{author} = $object->from;
108 0 $tvars{article}{letter} = substr($tvars{article}{dist},0,1);
109 }
110 }
111 }
112  
113 sub _parse_guid_report {
114 0 ▶ my @rows = $dbi->GetQuery('hash','GetMetabaseByGUID',$cgiparams{id});
Subroutine _parse_guid_report: not called CC=2 SCAR=17.9
115 0 ▶ return unless(@rows);
Branch: 1 branch
BranchTrueFalseTotal
unless @rows 0 0 0
116  
117 0 $tvars{article}{data} = $serializer->deserialize($rows[0]->{report});
118  
119 0 my $object = Labyrinth::Plugin::Metabase::Parser->new($tvars{article}{data});
120  
121 0 $tvars{article}{subject} = $object->subject;
122 0 $tvars{article}{from} = $object->from;
123 0 $tvars{article}{from} =~ s/\@.*//;
124 0 $tvars{article}{post} = $object->postdate;
125 0 $tvars{article}{date} = $object->date;
126  
127 0 $tvars{article}{dist} = $object->distribution;
128 0 $tvars{article}{version} = $object->version;
129 0 $tvars{article}{author} = $object->from;
130 0 $tvars{article}{letter} = substr($tvars{article}{dist},0,1);
131 }
132  
133 4 1;
134  
135 __END__
136  
137 =head1 SEE ALSO
138  
139 Labyrinth
140  
141 =head1 AUTHOR
142  
143 Barbie, <barbie@missbarbell.co.uk> for
144 Miss Barbell Productions, L<http://www.missbarbell.co.uk/>
145  
146 =head1 COPYRIGHT & LICENSE
147  
148 Copyright (C) 2010-2017 Barbie for Miss Barbell Productions
149 All Rights Reserved.
150  
151 This module is free software; you can redistribute it and/or
152 modify it under the Artistic License 2.0.
153  
154 =cut
« Labyrinth/Plugin/CPAN/Authors.pm ↑ Summary Labyrinth/Plugin/CPAN/Monitor.pm »