| 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
Condition66%2/3
$path and -e $path
MC/DC50%1/2
$path and -e $path
$path
-e $path
Truth table66%2/3
A and B
A= $pathB= -e $path
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 53 | my ($name, $format) = ($path =~ m/\/([^\/]+)\.([^.\/]+)$/); | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 53 | ▶ | Carp::croak qq/Bad file $path/ unless $name && $format; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$name and $format
MC/DC50%1/2
$name and $format
$name
$format
Truth table66%2/3
A and B
A= $nameB= $format
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 52 | my $filename = join '.' => $name, $format; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 52 | my $created; | |||||||||||||||||||||||||||
| 30 | 52 | ▶ | if ($name =~ s/^($TIMESTAMP_RE)-//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 52 | $created = Bootylicious::Timestamp->new(timestamp => $1)->epoch; | |||||||||||||||||||||||||||
| 32 | 52 | ▶ | return unless defined $created; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 52 | my $modified = stat($path)->mtime; | |||||||||||||||||||||||||||
| 36 | 52 | ▶ | $created ||= $modified; | ||||||||||||||||||||||||||
|
Condition33%1/3
$created ||= $modified
MC/DC0%0/2
$created ||= $modified
$created
$modified
Truth table33%1/3
A ||= B
A= $createdB= $modified
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||