line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::Condition::exists; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
3047
|
use Catmandu::Sane; |
|
17
|
|
|
|
|
46
|
|
|
17
|
|
|
|
|
135
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
17
|
|
|
17
|
|
147
|
use Moo; |
|
17
|
|
|
|
|
57
|
|
|
17
|
|
|
|
|
119
|
|
8
|
17
|
|
|
17
|
|
7198
|
use Catmandu::Util::Path qw(as_path); |
|
17
|
|
|
|
|
42
|
|
|
17
|
|
|
|
|
999
|
|
9
|
17
|
|
|
17
|
|
136
|
use namespace::clean; |
|
17
|
|
|
|
|
42
|
|
|
17
|
|
|
|
|
120
|
|
10
|
17
|
|
|
17
|
|
7379
|
use Catmandu::Fix::Has; |
|
17
|
|
|
|
|
42
|
|
|
17
|
|
|
|
|
180
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
with 'Catmandu::Fix::Condition::Builder'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _build_tester { |
17
|
44
|
|
|
44
|
|
443
|
my ($self) = @_; |
18
|
44
|
|
|
|
|
251
|
my $getter = as_path($self->path)->getter; |
19
|
|
|
|
|
|
|
sub { |
20
|
78
|
100
|
|
78
|
|
141
|
@{$getter->($_[0])} ? 1 : 0; |
|
78
|
|
|
|
|
1382
|
|
21
|
44
|
|
|
|
|
408
|
}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
__END__ |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=pod |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Catmandu::Fix::Condition::exists - only execute fixes if the path exists |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# uppercase the value of field 'foo' if the field 'oogly' exists |
37
|
|
|
|
|
|
|
if exists(oogly) |
38
|
|
|
|
|
|
|
upcase(foo) # foo => 'BAR' |
39
|
|
|
|
|
|
|
end |
40
|
|
|
|
|
|
|
# inverted |
41
|
|
|
|
|
|
|
unless exists(oogly) |
42
|
|
|
|
|
|
|
upcase(foo) # foo => 'bar' |
43
|
|
|
|
|
|
|
end |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SEE ALSO |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
L<Catmandu::Fix> |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |