Catmandu/Fix/parse_text.pm

filter: Statementstmt 97.3% 37 / 38 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 96.2% 51 / 53 CC 4 SCAR 7.0
CC
4
Cov
95%
__ANON__
4.0
_build_fixer
1.0
BEGIN
1.0
CRAP 2.0
« Catmandu.pm ↑ Summary Catmandu/Fix/Condition/SimpleAnyTest.pm »
1 package Catmandu::Fix::parse_text;
2  
3 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '1.2025';
6  
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Catmandu::Util::Path qw(as_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Catmandu::Util::Regex qw(as_regex);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 has path => (fix_arg => 1);
14 1 has pattern => (fix_arg => 1);
15  
16 1 with 'Catmandu::Fix::Builder';
17  
18 3 ▶sub _build_fixer {
Subroutine _build_fixer: called CC=1 SCAR=0.0
19 3 my ($self) = @_;
20 3 my $regex = as_regex($self->pattern);
21 as_path($self->path)->updater(
22 3 ▶ if_string => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
23 3 my $val = $_[0];
24 3 ▶ if ($val =~ m/$regex/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val =~ /$regex/) 3 0 3
25 3 ▶ if (@+ < 2) { # no capturing groups
Branch: 2 branches
BranchTrueFalseTotal
if (@+ < 2) { } 1 2 3
elsif (%+) { } 1 1 2
26 1 return undef, 1, 0;
27 }
28 elsif (%+) { # named capturing groups
29 1 return +{%+};
30 }
31 else { # numbered capturing groups
32 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 return [map {${$_}} 1 .. (@+ - 1)];
34 }
35 }
36 0 return undef, 1, 0;
37 }
38 3 );
39 }
40  
41 1 1;
42  
43 __END__
« Catmandu.pm ↑ Summary Catmandu/Fix/Condition/SimpleAnyTest.pm »