Catmandu/Fix/Condition/Builder/Simple.pm

filter: Statementstmt 100% 35 / 35 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod n/a totaltotal 98.0% 49 / 50 CC 3 SCAR 3.8
CC
3
Cov
97%
_build_tester
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« Catmandu/Fix/sum.pm ↑ Summary Catmandu/Importer/Text.pm »
1 package Catmandu::Fix::Condition::Builder::Simple;
2  
3 18 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 18 our $VERSION = '1.2025';
6  
7 18 ▶use List::SomeUtils qw(all_u any);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 ▶use Catmandu::Util::Path qw(as_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 18 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 18 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 18 with 'Catmandu::Fix::Condition::Builder';
13  
14 18 requires 'path';
15  
16 18 has mode => (is => 'lazy');
17 18 has value_tester => (is => 'lazy');
18  
19 25 ▶sub _build_mode {'all'}
Subroutine _build_mode: called CC=1 SCAR=0.0
20  
21 30 ▶sub _build_tester {
Subroutine _build_tester: called CC=3 SCAR=11.0
22 30 my ($self) = @_;
23 30 my $getter = as_path($self->path)->getter;
24 30 my $mode = $self->mode;
25 30 my $tester = $self->value_tester;
26 30 ▶ if ($mode eq 'all') {
Branch: 2 branches
BranchTrueFalseTotal
if ($mode eq 'all') { } 25 5 30
elsif ($mode eq 'any') { } 5 0 5
27 89 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
28 89 ▶ all_u {$tester->($_)} @{$getter->($_[0])};
Subroutine __ANON__: called CC=1 SCAR=0.0
29 25 };
30 }
31 elsif ($mode eq 'any') {
32 14 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
33 14 ▶ any {$tester->($_)} @{$getter->($_[0])};
Subroutine __ANON__: called CC=1 SCAR=0.0
34 5 };
35 }
36 }
37  
38 18 1;
39  
40 __END__
« Catmandu/Fix/sum.pm ↑ Summary Catmandu/Importer/Text.pm »