line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::Condition::marc_has; |
2
|
1
|
|
|
1
|
|
800
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
3
|
1
|
|
|
1
|
|
537
|
use Catmandu::Fix::marc_map; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
16
|
|
4
|
1
|
|
|
1
|
|
1540
|
use Catmandu::Fix::Condition::exists; |
|
1
|
|
|
|
|
19003
|
|
|
1
|
|
|
|
|
8
|
|
5
|
1
|
|
|
1
|
|
718
|
use Catmandu::Fix::set_field; |
|
1
|
|
|
|
|
7450
|
|
|
1
|
|
|
|
|
9
|
|
6
|
1
|
|
|
1
|
|
692
|
use Catmandu::Fix::remove_field; |
|
1
|
|
|
|
|
6124
|
|
|
1
|
|
|
|
|
10
|
|
7
|
1
|
|
|
1
|
|
123
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
668
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.21'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::Condition'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has marc_path => (fix_arg => 1); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub emit { |
17
|
1
|
|
|
1
|
0
|
16747
|
my ($self,$fixer,$label) = @_; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
7
|
my $perl; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
72
|
my $tmp_var = '_tmp_' . int(rand(9999)); |
22
|
1
|
|
|
|
|
19
|
my $marc_map = Catmandu::Fix::marc_map->new($self->marc_path , "$tmp_var.\$append"); |
23
|
1
|
|
|
|
|
1877
|
$perl .= $marc_map->emit($fixer,$label); |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
11
|
my $all_match = Catmandu::Fix::Condition::exists->new("$tmp_var"); |
26
|
1
|
|
|
|
|
1633
|
my $remove_field = Catmandu::Fix::remove_field->new($tmp_var); |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
1099
|
my $pass_fixes = $self->pass_fixes; |
29
|
1
|
|
|
|
|
4
|
my $fail_fixes = $self->fail_fixes; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
5
|
$all_match->pass_fixes([ $remove_field , @$pass_fixes ]); |
32
|
1
|
|
|
|
|
4
|
$all_match->fail_fixes([ $remove_field , @$fail_fixes ]); |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
5
|
$perl .= $all_match->emit($fixer,$label); |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
804
|
$perl; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Catmandu::Fix::Condition::marc_has - Test if a MARC (sub)field exists |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SYNOPSIS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# marc_has(MARC_PATH) |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
unless marc_has('245') |
48
|
|
|
|
|
|
|
add_field('error.$append','no 245 value!') |
49
|
|
|
|
|
|
|
end |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Evaluate the enclosing fixes only if the MARC (sub)field exists. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 marc_has(MARC_PATH) |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Evaluates to true when the MARC_PATH values exists, false otherwise. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SEE ALSO |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
L<Catmandu::Fix::marc_has_many> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |