line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::Condition::marc_has; |
2
|
1
|
|
|
1
|
|
570
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
3
|
1
|
|
|
1
|
|
389
|
use Catmandu::Fix::marc_map; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
662
|
use Catmandu::Fix::Condition::exists; |
|
1
|
|
|
|
|
8539
|
|
|
1
|
|
|
|
|
3
|
|
5
|
1
|
|
|
1
|
|
331
|
use Catmandu::Fix::set_field; |
|
1
|
|
|
|
|
3467
|
|
|
1
|
|
|
|
|
3
|
|
6
|
1
|
|
|
1
|
|
298
|
use Catmandu::Fix::remove_field; |
|
1
|
|
|
|
|
3257
|
|
|
1
|
|
|
|
|
4
|
|
7
|
1
|
|
|
1
|
|
48
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
269
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
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
|
1
|
|
|
1
|
0
|
13051
|
my ($self,$fixer,$label) = @_; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
2
|
my $perl; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
33
|
my $tmp_var = '_tmp_' . int(rand(9999)); |
22
|
1
|
|
|
|
|
8
|
my $marc_map = Catmandu::Fix::marc_map->new($self->marc_path , "$tmp_var.\$append"); |
23
|
1
|
|
|
|
|
1622
|
$perl .= $marc_map->emit($fixer,$label); |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
5
|
my $all_match = Catmandu::Fix::Condition::exists->new("$tmp_var"); |
26
|
1
|
|
|
|
|
1262
|
my $remove_field = Catmandu::Fix::remove_field->new($tmp_var); |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
918
|
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
|
|
|
|
|
4
|
$perl .= $all_match->emit($fixer,$label); |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
668
|
$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; |