blib/lib/App/RecordStream/Aggregator.pm

filter: Statementstmt 100% 52 / 52 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 5 totaltotal 92.9% 66 / 71 CC 7 SCAR 7.5
CC
7
Cov
100%
make_aggregators
4.0
map_initial
2.0
map_combine
2.0
CRAP 2.1
« blib/lib/App/RecordStream/Operation/fromsplit.pm ↑ Summary blib/lib/App/RecordStream/Aggregator/RecordForMaximum.pm »
1 package App::RecordStream::Aggregator;
2  
3 29 our $VERSION = "4.0.23";
4  
5 29 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 29 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 29 ▶use App::RecordStream::BaseRegistry;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 29 ▶use App::RecordStream::Site;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 29 ▶use base ('App::RecordStream::BaseRegistry');
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub make_aggregators
14 {
15 16 ▶ my $registry_class = shift;
Subroutine make_aggregators: called CC=4 SCAR=13.9
Pod undocumented
16  
17 16 my %ret;
18  
19 16 for my $input (@_)
20 {
21 22 my $spec = $input;
22 22 my $name;
23  
24 22 ▶ if($spec =~ /^(.*)=(.*)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($spec =~ /^(.*)=(.*)$/) 3 19 22
25 {
26 3 $name = $1;
27 3 $spec = $2;
28 }
29  
30 22 ▶ if(!defined($name))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name) 19 3 22
31 {
32 19 my @spec = split(/,/, $spec);
33 19 $name = join("_", map { my $n = $_; $n =~ s!/!_!; $n } @spec);
34 }
35  
36 22 $ret{$name} = $registry_class->parse_single_nameless_implementation($spec);
37 }
38  
39 16 return \%ret;
40 }
41  
42 sub map_initial
43 {
44 67 ▶ my ($aggrs) = @_;
Subroutine map_initial: called CC=2 SCAR=6.9
Pod undocumented
45  
46 67 my %ret;
47 67 for my $name (keys(%$aggrs))
48 {
49 83 $ret{$name} = $aggrs->{$name}->initial();
50 }
51  
52 67 return \%ret;
53 }
54  
55 sub map_combine
56 {
57 139 ▶ my ($aggrs, $cookies, $record) = @_;
Subroutine map_combine: called CC=2 SCAR=6.9
Pod undocumented
58  
59 139 my %ret;
60 139 for my $name (keys(%$aggrs))
61 {
62 187 $ret{$name} = $aggrs->{$name}->combine($cookies->{$name}, $record);
63 }
64  
65 139 return \%ret;
66 }
67  
68 sub map_squish
69 {
70 69 ▶ my ($aggrs, $cookies) = @_;
Subroutine map_squish: called CC=2 SCAR=6.9
Pod undocumented
71  
72 69 my $return_record = App::RecordStream::Record->new();
73 69 for my $name (keys(%$aggrs))
74 {
75 85 my $aggregator = $aggrs->{$name};
76 85 my $value = $aggregator->squish($cookies->{$name});
77 85 ${$return_record->guess_key_from_spec($name)} = $value;
78 }
79  
80 69 return $return_record;
81 }
82  
83 sub typename
84 {
85 18 ▶ return "aggregator";
Subroutine typename: called CC=1 SCAR=0.0
Pod undocumented
86 }
87  
88 29 1;
« blib/lib/App/RecordStream/Operation/fromsplit.pm ↑ Summary blib/lib/App/RecordStream/Aggregator/RecordForMaximum.pm »