line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::Condition::marc_has_many; |
2
|
2
|
|
|
2
|
|
64618
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
123205
|
|
|
2
|
|
|
|
|
11
|
|
3
|
2
|
|
|
2
|
|
645
|
use Catmandu::Fix::marc_map; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
12
|
|
4
|
2
|
|
|
2
|
|
446
|
use Catmandu::Fix::Condition::exists; |
|
2
|
|
|
|
|
9371
|
|
|
2
|
|
|
|
|
10
|
|
5
|
2
|
|
|
2
|
|
344
|
use Catmandu::Fix::set_field; |
|
2
|
|
|
|
|
3803
|
|
|
2
|
|
|
|
|
9
|
|
6
|
2
|
|
|
2
|
|
352
|
use Catmandu::Fix::remove_field; |
|
2
|
|
|
|
|
3205
|
|
|
2
|
|
|
|
|
10
|
|
7
|
2
|
|
|
2
|
|
82
|
use Moo; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
12
|
|
8
|
2
|
|
|
2
|
|
594
|
use Catmandu::Fix::Has; |
|
2
|
|
|
|
|
25
|
|
|
2
|
|
|
|
|
12
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.20'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::Condition'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has marc_path => (fix_arg => 1); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub emit { |
17
|
4
|
|
|
4
|
0
|
240
|
my ($self,$fixer,$label) = @_; |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
6
|
my $perl; |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
12
|
my $tmp_var = '_tmp_' . int(rand(9999)); |
22
|
4
|
|
|
|
|
62
|
my $marc_map = Catmandu::Fix::marc_map->new( |
23
|
|
|
|
|
|
|
$self->marc_path , |
24
|
|
|
|
|
|
|
"$tmp_var" , |
25
|
|
|
|
|
|
|
-split=>1 , |
26
|
|
|
|
|
|
|
-nested_arrays=>1 |
27
|
|
|
|
|
|
|
); |
28
|
4
|
|
|
|
|
410
|
$perl .= $marc_map->emit($fixer,$label); |
29
|
|
|
|
|
|
|
|
30
|
4
|
100
|
|
|
|
74
|
my $all_match = |
31
|
|
|
|
|
|
|
$self->marc_path =~ m{^...(\/[0-9]+-[0-9]+)?$} ? |
32
|
|
|
|
|
|
|
Catmandu::Fix::Condition::exists->new("$tmp_var.1") : |
33
|
|
|
|
|
|
|
Catmandu::Fix::Condition::exists->new("$tmp_var.0.1"); |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
|
|
466
|
my $remove_field = Catmandu::Fix::remove_field->new($tmp_var); |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
288
|
my $pass_fixes = $self->pass_fixes; |
38
|
4
|
|
|
|
|
9
|
my $fail_fixes = $self->fail_fixes; |
39
|
|
|
|
|
|
|
|
40
|
4
|
|
|
|
|
10
|
$all_match->pass_fixes([ @$pass_fixes ]); |
41
|
4
|
|
|
|
|
7
|
$all_match->fail_fixes([ @$fail_fixes ]); |
42
|
|
|
|
|
|
|
|
43
|
4
|
|
|
|
|
11
|
$perl .= $all_match->emit($fixer,$label); |
44
|
|
|
|
|
|
|
|
45
|
4
|
|
|
|
|
1900
|
$perl; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Catmandu::Fix::Condition::marc_has_many - Test if a MARC has more than one (sub)field |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 SYNOPSIS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# marc_has_many(MARC_PATH) |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
if marc_has_many('245') |
57
|
|
|
|
|
|
|
add_field('error.$append','more than one 245!') |
58
|
|
|
|
|
|
|
end |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 DESCRIPTION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Evaluate the enclosing fixes only if the MARC has more than one (sub)field. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 METHODS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 marc_has_many(MARC_PATH) |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Evaluates to true when the MARC has more than one (sub)field, false otherwise. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SEE ALSO |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L<Catmandu::Fix::marc_has> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |