line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::Condition::is_false; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
856
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
8
|
use Moo; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
19
|
|
8
|
1
|
|
|
1
|
|
439
|
use Catmandu::Util qw(is_number is_string is_bool); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
86
|
|
9
|
1
|
|
|
1
|
|
7
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
10
|
1
|
|
|
1
|
|
357
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
17
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
13
|
|
|
|
|
|
|
has strict => (fix_opt => 1); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'Catmandu::Fix::Condition::Builder::Simple'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _build_value_tester { |
18
|
2
|
|
|
2
|
|
21
|
my ($self) = @_; |
19
|
2
|
100
|
|
|
|
12
|
if ($self->strict) { |
20
|
|
|
|
|
|
|
sub { |
21
|
5
|
100
|
|
5
|
|
16
|
is_bool($_[0]) && !$_[0]; |
22
|
1
|
|
|
|
|
6
|
}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
|
|
|
|
|
|
sub { |
26
|
6
|
|
|
6
|
|
12
|
my $val = $_[0]; |
27
|
6
|
100
|
100
|
|
|
22
|
(is_bool($val) && !$val) |
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
28
|
|
|
|
|
|
|
|| (is_number($val) && $val == 0) |
29
|
|
|
|
|
|
|
|| (is_string($val) && $val eq 'false'); |
30
|
1
|
|
|
|
|
7
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=pod |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Catmandu::Fix::Condition::is_false - only execute fixes if all path values are the boolean false, 0 or "false" |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
if is_false(data.*.has_error) |
47
|
|
|
|
|
|
|
... |
48
|
|
|
|
|
|
|
end |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# strict only matches a real bool, not 0 or "0" or "false" |
51
|
|
|
|
|
|
|
if is_false(data.*.has_error, strict: 1) |
52
|
|
|
|
|
|
|
... |
53
|
|
|
|
|
|
|
end |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SEE ALSO |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
L<Catmandu::Fix> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |