blib/lib/Catmandu/Fix/Condition/is_true.pm

filter: Statementstmt 100% 21 / 21 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 96.5% 28 / 29 CC 2 SCAR 2.9
CC
2
Cov
100%
emit_test
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« blib/lib/Catmandu/Fix/Condition/is_false.pm ↑ Summary blib/lib/Catmandu/Importer/Multi.pm »
1 package Catmandu::Fix::Condition::is_true;
2  
3 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '1.0201_02';
6  
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 has path => (fix_arg => 1);
12 1 has strict => (fix_opt => 1);
13  
14 1 with 'Catmandu::Fix::Condition::SimpleAllTest';
15  
16 sub emit_test {
17 2 ▶ my ($self, $var) = @_;
Subroutine emit_test: called CC=2 SCAR=6.9
Pod undocumented
18 2 ▶ if ($self->strict) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->strict) 1 1 2
19 1 return "(is_bool(${var}) && ${var})";
20 }
21 1 "((is_bool(${var}) && ${var}) || (is_number(${var}) && ${var} == 1) || (is_string(${var}) && ${var} eq 'true'))";
22 }
23  
24 1 1;
25  
26 __END__
27  
28 =pod
29  
30 =head1 NAME
31  
32 Catmandu::Fix::Condition::is_true - only execute fixes if all path values are the boolean true, 1 or "true"
33  
34 =head1 SYNOPSIS
35  
36 if is_true(data.*.has_error)
37 ...
38 end
39  
40 # strict only matches a real bool, not 1 or "1" or "true"
41 if is_true(data.*.has_error, strict: 1)
42 ...
43 end
44  
45 =head1 SEE ALSO
46  
47 L<Catmandu::Fix>
48  
49 =cut
« blib/lib/Catmandu/Fix/Condition/is_false.pm ↑ Summary blib/lib/Catmandu/Importer/Multi.pm »