| 1 | package Catmandu::Fix::marc_spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use Catmandu::Sane; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use Catmandu::MARC; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Catmandu::Fix::Has; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | with 'Catmandu::Fix::Base'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | our $VERSION = '1.33'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | has spec => ( fix_arg=> 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | has path => ( fix_arg=> 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 5 | has split => ( fix_opt=> 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | has join => ( fix_opt=> 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | has value => ( fix_opt=> 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | has pluck => ( fix_opt=> 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | has invert => ( fix_opt=> 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | has nested_arrays => ( fix_opt=> 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 128 | ▶ | sub emit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emit: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 128 | my ( $self, $fixer ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 128 | my $path = $fixer->split_path( $self->path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 128 | my $key = $path->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 128 | my $marc_obj = Catmandu::MARC->instance; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # Precompile the marc_path to gain some speed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 128 | my $spec = $marc_obj->parse_marc_spec( $self->spec ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 128 | my $marc = $fixer->capture($marc_obj); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 128 | my $marc_spec = $fixer->capture($spec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 128 | ▶ | my $marc_opt = $fixer->capture({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%10/10
$self->join // ""
$self->split // 0
$self->pluck // 0
$self->nested_arrays // 0
$self->invert // 0
MC/DC100%1/1
$self->join // ""
$self->join
MC/DC100%1/1
$self->split // 0
$self->split
MC/DC100%1/1
$self->pluck // 0
$self->pluck
MC/DC100%1/1
$self->nested_arrays // 0
$self->nested_arrays
MC/DC100%1/1
$self->invert // 0
$self->invert
Truth table100%2/2
A
A= $self->join
Truth table100%2/2
A
A= $self->split
Truth table100%2/2
A
A= $self->pluck
Truth table100%2/2
A
A= $self->nested_arrays
Truth table100%2/2
A
A= $self->invert
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | '-join' => $self->join // '' , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | '-split' => $self->split // 0 , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | '-pluck' => $self->pluck // 0 , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | '-nested_arrays' => $self->nested_arrays // 0 , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | '-invert' => $self->invert // 0 , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | '-value' => $self->value , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | '-force_array' => ($key =~ /^(\$.*|[0-9]+)$/) ? 1 : 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 128 | my $var = $fixer->var; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 128 | my $result = $fixer->generate_var; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 128 | my $current_value = $fixer->generate_var; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 128 | my $perl = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 128 | $perl .= $fixer->emit_declare_vars($current_value, "[]"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 128 | $perl .=<<EOF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | if (defined(my ${result} = ${marc}->marc_spec( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ${var}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ${marc_spec}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ${marc_opt})) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ${result} = ref(${result}) ? ${result} : [${result}]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | for ${current_value} (\@{${result}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | $perl .= $fixer->emit_create_path( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | $var, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 128 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 128 | my $var2 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 128 | "${var2} = ${current_value}" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 128 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 128 | $perl .=<<EOF; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | EOF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 128 | $perl; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||