blib/lib/Bootylicious/DocumentStatLoader.pm

filter: Statementstmt 100% 32 / 32 Branchbran 75.0% 6 / 8 Conditioncond 55.5% 5 / 9 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 82.2% 51 / 62 CC 8 SCAR 17.3
CC
8
Cov
88%
load
8.5
BEGIN
1.0
BEGIN
1.0
CRAP 5.6
« blib/lib/Bootylicious/Plugin/BootyHelpers.pm ↑ Summary blib/lib/Bootylicious/TagCloud.pm »
1 package Bootylicious::DocumentStatLoader;
2  
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 12 ▶use base 'Mojo::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 12 ▶use Bootylicious::Timestamp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 12 require Carp;
11 12 ▶use File::stat;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 12 my $TIMESTAMP_RE = qr/(\d\d\d\d)(\d?\d)(\d?\d)(?:T(\d\d):?(\d\d):?(\d\d))?/;
14  
15 12 __PACKAGE__->attr('path');
16  
17 sub load {
18 54 ▶ my $self = shift;
Subroutine load: called CC=8 SCAR=21.4
Pod undocumented
19 54 my $path = $self->path;
20  
21 54 ▶ Carp::croak qq/Can't load: $!/ unless $path && -e $path;
Branch: 1 branch
BranchTrueFalseTotal
unless $path and -e $path 1 53 54
Condition66%2/3
$path and -e $path
!ll&&!rl&&r
0153
MC/DC50%1/2
$path and -e $path
$path -e $path
Truth table66%2/3
A and B
A= $pathB= -e $path
ABresult
0X0
100
111
22  
23 53 my ($name, $format) = ($path =~ m/\/([^\/]+)\.([^.\/]+)$/);
24  
25 53 ▶ Carp::croak qq/Bad file $path/ unless $name && $format;
Branch: 1 branch
BranchTrueFalseTotal
unless $name and $format 1 52 53
Condition66%2/3
$name and $format
!ll&&!rl&&r
1052
MC/DC50%1/2
$name and $format
$name $format
Truth table66%2/3
A and B
A= $nameB= $format
ABresult
0X0
100
111
26  
27 52 my $filename = join '.' => $name, $format;
28  
29 52 my $created;
30 52 ▶ if ($name =~ s/^($TIMESTAMP_RE)-//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ s/^($TIMESTAMP_RE)-//) 52 0 52
31 52 $created = Bootylicious::Timestamp->new(timestamp => $1)->epoch;
32 52 ▶ return unless defined $created;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $created 0 52 52
33 }
34  
35 52 my $modified = stat($path)->mtime;
36 52 ▶ $created ||= $modified;
Condition33%1/3
$created ||= $modified
l!l&&r!l&&!r
5200
MC/DC0%0/2
$created ||= $modified
$created $modified
Truth table33%1/3
A ||= B
A= $createdB= $modified
ABresult
1X1
011
000
37  
38 return {
39 52 name => $name,
40 filename => $filename,
41 format => $format,
42 created => Bootylicious::Timestamp->new(epoch => $created),
43 modified => Bootylicious::Timestamp->new(epoch => $modified)
44 };
45 }
46  
47 12 1;
« blib/lib/Bootylicious/Plugin/BootyHelpers.pm ↑ Summary blib/lib/Bootylicious/TagCloud.pm »