Scraper/Utils.pm

filter: Statementstmt 48.5% 17 / 35 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 62.5% 5 / 8 Podpod n/a totaltotal 35.4% 22 / 62 CC 9 SCAR 25.3
CC
9
Cov
33%
_force_arrayref
20.0
_datetime
20.0
_uri
12.0
CRAP 12.6
« Scraper/Plugin/ViewBBS.pm ↑ Summary Scraper.pm »
1 package WWW::Mixi::Scraper::Utils;
2
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base qw/Exporter/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use URI::QueryParam;
Subroutine BEGIN: called CC=1 SCAR=0.0
8
9 1 our @EXPORT_OK = qw( _force_arrayref _uri _datetime );
10
11 0 ▶sub _force_arrayref {
Subroutine _force_arrayref: not called CC=4 SCAR=30.0
12 0 my $thingy = shift;
13
14 0 ▶ return [] if !defined $thingy || $thingy eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $thingy or $thingy eq "" 0 0 0
Condition0%0/3
not defined $thingy or $thingy eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $thingy or $thingy eq ""
not defined $thingy $thingy eq ""
Truth table0%0/3
not(A) or B
A= not defined $thingyB= $thingy eq ""
ABresult
1X1
011
000
15 0 ▶ return [$thingy] if ref $thingy ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $thingy ne "ARRAY" 0 0 0
16 0 return $thingy;
17 }
18
19 0 ▶sub _datetime {
Subroutine _datetime: not called CC=4 SCAR=30.0
20 0 my $date = shift;
21
22 0 ▶ unless ( defined $date ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $date) 0 0 0
23 0 warn "datetime is not defined"; return;
24 }
25
26 0 my $time;
27 0 ▶ if ( $date =~ s/\s*(\d+:\d+(?::\d+)?)\s*$// ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($date =~ s/\s*(\d+:\d+(?::\d+)?)\s*$//) 0 0 0
28 0 $time = $1;
29 }
30
31 0 $date =~ s/\D/\-/g;
32 0 $date =~ s/\-+$//;
33
34 0 ▶ return $time ? "$date $time" : $date; # should be DateTime object?
Branch: 1 branch
BranchTrueFalseTotal
$time ? : 0 0 0
35 }
36
37 0 ▶sub _uri {
Subroutine _uri: not called CC=3 SCAR=24.8
38 0 my $uri = URI->new(shift);
39 0 ▶ $uri->authority('mixi.jp') unless $uri->authority;
Branch: 1 branch
BranchTrueFalseTotal
unless $uri->authority 0 0 0
40 0 ▶ $uri->scheme('http') unless $uri->scheme;
Branch: 1 branch
BranchTrueFalseTotal
unless $uri->scheme 0 0 0
41 0 return $uri;
42 }
43
44 1 1;
45
46 __END__
« Scraper/Plugin/ViewBBS.pm ↑ Summary Scraper.pm »