line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::Condition::all_match; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
1238
|
use Catmandu::Sane; |
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
54
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
45
|
use Moo; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
43
|
|
8
|
6
|
|
|
6
|
|
2235
|
use Catmandu::Util qw(is_value); |
|
6
|
|
|
|
|
20
|
|
|
6
|
|
|
|
|
374
|
|
9
|
6
|
|
|
6
|
|
2680
|
use Catmandu::Util::Regex qw(as_regex); |
|
6
|
|
|
|
|
44
|
|
|
6
|
|
|
|
|
375
|
|
10
|
6
|
|
|
6
|
|
46
|
use namespace::clean; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
48
|
|
11
|
6
|
|
|
6
|
|
1973
|
use Catmandu::Fix::Has; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
45
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
14
|
|
|
|
|
|
|
has pattern => (fix_arg => 1); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
with 'Catmandu::Fix::Condition::Builder::Simple'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _build_value_tester { |
19
|
11
|
|
|
11
|
|
118
|
my ($self) = @_; |
20
|
11
|
|
|
|
|
67
|
my $re = as_regex($self->pattern); |
21
|
|
|
|
|
|
|
sub { |
22
|
33
|
|
|
33
|
|
68
|
my $v = $_[0]; |
23
|
33
|
50
|
|
|
|
793
|
is_value($v) && $v =~ $re; |
24
|
11
|
|
|
|
|
70
|
}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__END__ |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=pod |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Catmandu::Fix::Condition::all_match - only execute fixes if all path values match the given regex |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# uppercase the value of field 'foo' if all members of 'oogly' have the value 'doogly' |
40
|
|
|
|
|
|
|
if all_match(oogly.*, "doogly") |
41
|
|
|
|
|
|
|
upcase(foo) # foo => 'BAR' |
42
|
|
|
|
|
|
|
end |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# case insensitive search for 'doogly' in all 'oogly' |
45
|
|
|
|
|
|
|
if all_match(oogly.*, "(?i)doogly") |
46
|
|
|
|
|
|
|
... |
47
|
|
|
|
|
|
|
end |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 SEE ALSO |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
L<Catmandu::Fix> |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |