| 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
| |||||||||||
| 30 | 4 | as_path($self->path)->updater(if_array_ref => $cb); | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 1 | 1; | |||||||||
| 34 | |||||||||||
| 35 | __END__ | ||||||||||