blib/lib/Catmandu/Fix/sum.pm

filter: Statementstmt 100% 21 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 96.4% 27 / 28 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Catmandu/Fix/Base.pm ↑ Summary blib/lib/Catmandu/Fix/uniq.pm »
1 package Catmandu::Fix::sum;
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 List::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 has path => (fix_arg => 1);
13  
14 1 with 'Catmandu::Fix::SimpleGetValue';
15  
16 sub emit_value {
17 5 ▶ my ($self, $var) = @_;
Subroutine emit_value: called CC=1 SCAR=0.0
Pod undocumented
18  
19 5 "if (is_array_ref(${var})) {"
20 . "${var} = List::Util::sum(\@{${var}}) // 0;" . "}";
21 }
22  
23 1 1;
24  
25 __END__
26  
27 =pod
28  
29 =head1 NAME
30  
31 Catmandu::Fix::sum - replace the value of an array field with the sum of its elements
32  
33 =head1 SYNOPSIS
34  
35 # e.g. numbers => [2, 3]
36 sum(numbers)
37 # numbers => 5
38  
39 =head1 SEE ALSO
40  
41 L<Catmandu::Fix>
42  
43 =cut
« blib/lib/Catmandu/Fix/Base.pm ↑ Summary blib/lib/Catmandu/Fix/uniq.pm »