| 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
Condition0%0/3
not defined $thingy or $thingy eq ""
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 ""
| |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | return [$thingy] if ref $thingy ne 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $uri->scheme('http') unless $uri->scheme; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | return $uri; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | 1; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||||||||||