line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::Condition::marc_all_match; |
2
|
4
|
|
|
4
|
|
48694
|
use Catmandu::Sane; |
|
4
|
|
|
|
|
247131
|
|
|
4
|
|
|
|
|
29
|
|
3
|
4
|
|
|
4
|
|
1739
|
use Catmandu::Fix::marc_map; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
21
|
|
4
|
4
|
|
|
4
|
|
1702
|
use Catmandu::Fix::Condition::all_match; |
|
4
|
|
|
|
|
47486
|
|
|
4
|
|
|
|
|
17
|
|
5
|
4
|
|
|
4
|
|
1294
|
use Catmandu::Fix::set_field; |
|
4
|
|
|
|
|
10839
|
|
|
4
|
|
|
|
|
58
|
|
6
|
4
|
|
|
4
|
|
1575
|
use Catmandu::Fix::remove_field; |
|
4
|
|
|
|
|
13398
|
|
|
4
|
|
|
|
|
16
|
|
7
|
4
|
|
|
4
|
|
211
|
use Moo; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
34
|
|
8
|
4
|
|
|
4
|
|
1093
|
use Catmandu::Fix::Has; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
18
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.20'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Fix::Condition'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has marc_path => (fix_arg => 1); |
15
|
|
|
|
|
|
|
has value => (fix_arg => 1); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub emit { |
18
|
5
|
|
|
5
|
0
|
10555
|
my ($self,$fixer,$label) = @_; |
19
|
|
|
|
|
|
|
|
20
|
5
|
|
|
|
|
12
|
my $perl; |
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
|
|
132
|
my $tmp_var = '_tmp_' . int(rand(9999)); |
23
|
5
|
|
|
|
|
107
|
my $marc_map = Catmandu::Fix::marc_map->new($self->marc_path , "$tmp_var.\$append"); |
24
|
5
|
|
|
|
|
613
|
$perl .= $marc_map->emit($fixer,$label); |
25
|
|
|
|
|
|
|
|
26
|
5
|
|
|
|
|
81
|
my $all_match = Catmandu::Fix::Condition::all_match->new("$tmp_var.*",$self->value); |
27
|
5
|
|
|
|
|
3906
|
my $remove_field = Catmandu::Fix::remove_field->new($tmp_var); |
28
|
|
|
|
|
|
|
|
29
|
5
|
|
|
|
|
2314
|
my $pass_fixes = $self->pass_fixes; |
30
|
5
|
|
|
|
|
18
|
my $fail_fixes = $self->fail_fixes; |
31
|
|
|
|
|
|
|
|
32
|
5
|
|
|
|
|
27
|
$all_match->pass_fixes([ $remove_field , @$pass_fixes ]); |
33
|
5
|
|
|
|
|
16
|
$all_match->fail_fixes([ $remove_field , @$fail_fixes ]); |
34
|
|
|
|
|
|
|
|
35
|
5
|
|
|
|
|
19
|
$perl .= $all_match->emit($fixer,$label); |
36
|
|
|
|
|
|
|
|
37
|
5
|
|
|
|
|
4251
|
$perl; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Catmandu::Fix::Condition::marc_all_match - Test if a MARC (sub)field matches a value |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# marc_all_match(MARC_PATH,REGEX) |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Match when 245 contains the value "My funny title" |
49
|
|
|
|
|
|
|
if marc_all_match('245','My funny title') |
50
|
|
|
|
|
|
|
add_field('my.funny.title','true') |
51
|
|
|
|
|
|
|
end |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Match when 245a contains the value "My funny title" |
54
|
|
|
|
|
|
|
if marc_all_match('245a','My funny title') |
55
|
|
|
|
|
|
|
add_field('my.funny.title','true') |
56
|
|
|
|
|
|
|
end |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Match when all 650 fields contain digits |
59
|
|
|
|
|
|
|
if marc_all_match('650','[0-9]') |
60
|
|
|
|
|
|
|
add_field('has_digits','true') |
61
|
|
|
|
|
|
|
end |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Evaluate the enclosing fixes only if the MARC (sub)field matches a |
66
|
|
|
|
|
|
|
regular expression. When the MARC field is a repeated fiels, then all |
67
|
|
|
|
|
|
|
the MARC fields should match the regular expression. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 METHODS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 marc_all_match(MARC_PATH, REGEX) |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Evaluates to true when all MARC_PATH values matches the REGEX, false otherwise. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SEE ALSO |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
L<Catmandu::Fix::Condition::marc_any_match> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |