| 1 | package Catmandu::Fix::Bind::pica_each; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | our $VERSION = '1.18'; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Catmandu::Sane; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Catmandu::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Catmandu::Fix::Has; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use PICA::Path; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Scalar::Util 'reftype'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | with 'Catmandu::Fix::Bind', 'Catmandu::Fix::Bind::Group'; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | has done => ( is => 'ro' ); | |||||||||||||||||||||||||||
| 15 | has pica_path => ( | ||||||||||||||||||||||||||||
| 16 | fix_arg => 1, | ||||||||||||||||||||||||||||
| 17 | 4 | ▶ | coerce => sub { $_[0] ne '....' ? PICA::Path->new( $_[0] ) : undef }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | default => sub { '....' } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 4 | ▶ | sub unit { | ||||||||||||||||||||||||||
|
Subroutine
unit: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | 4 | my ( $self, $data ) = @_; | |||||||||||||||||||||||||||
| 23 | 4 | $self->{done} = 0; | |||||||||||||||||||||||||||
| 24 | 4 | $data; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 4 | ▶ | sub bind { | ||||||||||||||||||||||||||
|
Subroutine
bind: called CC=9 SCAR=22.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 4 | my ( $self, $data, $code ) = @_; | |||||||||||||||||||||||||||
| 29 | 4 | ▶ | return $data if $self->done or reftype( $data->{record} ) ne 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->done or builtin::reftype($data->{"record"}) ne "ARRAY"
MC/DC0%0/2
$self->done or builtin::reftype($data->{"record"}) ne "ARRAY"
$self->done
builtin::reftype($data->{"record"}) ne "ARRAY"
Truth table33%1/3
A or B
A= $self->doneB= builtin::reftype($data->{"record"}) ne "ARRAY"
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 4 | my $fields = $data->{record}; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 4 | my @new = (); | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 4 | for my $field ( @{$fields} ) { | |||||||||||||||||||||||||||
| 36 | 91 | ▶ | if ( $self->pica_path && !$self->pica_path->match_field($field) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->pica_path and not $self->pica_path->match_field($field)
MC/DC100%2/2
$self->pica_path and not $self->pica_path->match_field($field)
$self->pica_path
not $self->pica_path->match_field($field)
Truth table100%3/3
A and not(B)
A= $self->pica_pathB= not $self->pica_path->match_field($field)
| |||||||||||||||||||||||||||||
| 37 | 58 | push @new, $field; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | else { | ||||||||||||||||||||||||||||
| 40 | 33 | $data->{record} = [$field]; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 33 | my $fixed = $code->($data); | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 33 | push @new, @{ $fixed->{record} } | |||||||||||||||||||||||||||
| 45 | 33 | ▶ | if defined($fixed) && exists $fixed->{record}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $fixed and exists $fixed->{"record"}
MC/DC0%0/2
defined $fixed and exists $fixed->{"record"}
defined $fixed
exists $fixed->{"record"}
Truth table33%1/3
A and B
A= defined $fixedB= exists $fixed->{"record"}
| |||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 4 | ▶ | $data->{record} = \@new if exists $data->{record}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 4 | $self->{done} = 1; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 4 | $data; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | 1; | |||||||||||||||||||||||||||
| 57 | __END__ | ||||||||||||||||||||||||||||