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