Catmandu/Fix/filter.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 100% 49 / 49 CC 2 SCAR 1.7
CC
2
Cov
100%
_build_fixer
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Catmandu/Buffer.pm ↑ Summary Catmandu/ArrayIterator.pm »
1 package Catmandu::Fix::filter;
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 Catmandu::Util qw(is_array_ref);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Catmandu::Util::Regex qw(as_regex);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Catmandu::Util::Path qw(as_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 has path => (fix_arg => 1);
15 1 has search => (fix_arg => 1);
16 1 has invert => (fix_opt => 1);
17  
18 1 with 'Catmandu::Fix::Builder';
19  
20 4 ▶sub _build_fixer {
Subroutine _build_fixer: called CC=2 SCAR=6.9
21 4 my ($self) = @_;
22 4 my $regex = as_regex($self->search);
23 my $cb = $self->invert
24 1 ▶ ? sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
25 1 [grep {!m/$regex/} @{$_[0]}];
26 }
27 3 ▶ : sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
28 3 [grep {m/$regex/} @{$_[0]}];
29 4 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$self->invert ? : 1 3 4
30 4 as_path($self->path)->updater(if_array_ref => $cb);
31 }
32  
33 1 1;
34  
35 __END__
« Catmandu/Buffer.pm ↑ Summary Catmandu/ArrayIterator.pm »