blib/lib/Bootylicious/FileIteratorLoader.pm

filter: Statementstmt 100% 46 / 46 Branchbran 100% 4 / 4 Conditioncond 66.6% 4 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 3 totaltotal 88.8% 64 / 72 CC 6 SCAR 9.5
CC
6
Cov
96%
load
5.0
files
2.0
BEGIN
1.0
CRAP 2.6
« blib/lib/Bootylicious/Plugin/GoogleAnalytics.pm ↑ Summary blib/lib/Bootylicious/Decorator.pm »
1 package Bootylicious::FileIteratorLoader;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 ▶use base 'Mojo::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 __PACKAGE__->attr('element_class');
9 11 __PACKAGE__->attr('filter');
10 11 __PACKAGE__->attr('root');
11 11 __PACKAGE__->attr('path');
12  
13 11 ▶use Mojo::ByteStream;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 11 ▶use Mojo::Loader qw(load_class);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 11 ▶use Bootylicious::Iterator;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 sub files {
18 31 ▶ my $self = shift;
Subroutine files: called CC=2 SCAR=6.9
Pod undocumented
19  
20 31 my $root = $self->root;
21 31 my $path = $self->path;
22  
23 31 ▶ return glob $root ? "$root/*" : "$path*";
Branch: 1 branch
BranchTrueFalseTotal
$root ? : 18 13 31
24 }
25  
26 sub create_element {
27 74 ▶ my $self = shift;
Subroutine create_element: called CC=1 SCAR=0.0
Pod undocumented
28  
29 74 load_class($self->element_class);
30  
31 74 return $self->element_class->new;
32 }
33  
34 sub load {
35 31 ▶ my $self = shift;
Subroutine load: called CC=5 SCAR=16.1
Pod undocumented
36 31 my $iterator = shift;
37  
38 31 ▶ $iterator ||= Bootylicious::Iterator->new;
Condition66%2/3
$iterator ||= "Bootylicious::Iterator"->new
l!l&&r!l&&!r
14170
MC/DC0%0/2
$iterator ||= "Bootylicious::Iterator"->new
$iterator "Bootylicious::Iterator"->new
Truth table66%2/3
A ||= B
A= $iteratorB= "Bootylicious::Iterator"->new
ABresult
1X1
011
000
39  
40 31 my $filter = $self->filter;
41  
42 31 my @elements = ();
43 31 foreach my $file ($self->files) {
44 89 $file = Mojo::ByteStream->new($file)->decode('UTF-8')->to_string;
45  
46 89 my $basename = File::Basename::basename($file);
47 89 ▶ next if $filter && $basename !~ m/$filter/;
Branch: 1 branch
BranchTrueFalseTotal
if $filter and not $basename =~ /$filter/ 15 74 89
Condition66%2/3
$filter and not $basename =~ /$filter/
!ll&&!rl&&r
07415
MC/DC50%1/2
$filter and not $basename =~ /$filter/
$filter not $basename =~ /$filter/
Truth table66%2/3
A and not(B)
A= $filterB= not $basename =~ /$filter/
ABresult
0X0
100
111
48  
49 74 my $element = $self->create_element;
50 74 $element->load($file);
51  
52 74 push @elements, $element;
53 }
54  
55 $iterator->elements(
56 31 [sort { $b->created->epoch <=> $a->created->epoch } @elements]);
57 31 $iterator->rewind;
58  
59 31 return $iterator;
60 }
61  
62 11 1;
« blib/lib/Bootylicious/Plugin/GoogleAnalytics.pm ↑ Summary blib/lib/Bootylicious/Decorator.pm »