line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::Condition::marc_has; |
2
|
1
|
|
|
1
|
|
1078
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
49
|
|
3
|
1
|
|
|
1
|
|
1241
|
use Catmandu::Fix::marc_map; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
15
|
|
4
|
1
|
|
|
1
|
|
574
|
use Catmandu::Fix::Condition::exists; |
|
1
|
|
|
|
|
13259
|
|
|
1
|
|
|
|
|
5
|
|
5
|
1
|
|
|
1
|
|
442
|
use Catmandu::Fix::set_field; |
|
1
|
|
|
|
|
5941
|
|
|
1
|
|
|
|
|
9
|
|
6
|
1
|
|
|
1
|
|
510
|
use Catmandu::Fix::remove_field; |
|
1
|
|
|
|
|
5121
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
64
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
527
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.19'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::Condition'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has marc_path => (fix_arg => 1); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub emit { |
17
|
1
|
|
|
1
|
0
|
14693
|
my ($self,$fixer,$label) = @_; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
3
|
my $perl; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
39
|
my $tmp_var = '_tmp_' . int(rand(9999)); |
22
|
1
|
|
|
|
|
12
|
my $marc_map = Catmandu::Fix::marc_map->new($self->marc_path , "$tmp_var.\$append"); |
23
|
1
|
|
|
|
|
1744
|
$perl .= $marc_map->emit($fixer,$label); |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
7
|
my $all_match = Catmandu::Fix::Condition::exists->new("$tmp_var"); |
26
|
1
|
|
|
|
|
1418
|
my $remove_field = Catmandu::Fix::remove_field->new($tmp_var); |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
1037
|
my $pass_fixes = $self->pass_fixes; |
29
|
1
|
|
|
|
|
4
|
my $fail_fixes = $self->fail_fixes; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
6
|
$all_match->pass_fixes([ $remove_field , @$pass_fixes ]); |
32
|
1
|
|
|
|
|
5
|
$all_match->fail_fixes([ $remove_field , @$fail_fixes ]); |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
5
|
$perl .= $all_match->emit($fixer,$label); |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
699
|
$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; |