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 30 our $VERSION = "4.0.25";
4  
5 30 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 30 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 30 ▶use App::RecordStream::BaseRegistry;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 30 ▶use App::RecordStream::Site;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 30 ▶use base ('App::RecordStream::BaseRegistry');
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub make_aggregators
14 18 ▶{
Subroutine make_aggregators: called CC=4 SCAR=13.9
Pod undocumented
15 18 my $registry_class = shift;
16  
17 18 my %ret;
18  
19 18 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 18 return \%ret;
40 }
41  
42 sub map_initial
43 71 ▶{
Subroutine map_initial: called CC=2 SCAR=6.9
Pod undocumented
44 71 my ($aggrs) = @_;
45  
46 71 my %ret;
47 71 for my $name (keys(%$aggrs))
48 {
49 87 $ret{$name} = $aggrs->{$name}->initial();
50 }
51  
52 71 return \%ret;
53 }
54  
55 sub map_combine
56 149 ▶{
Subroutine map_combine: called CC=2 SCAR=6.9
Pod undocumented
57 149 my ($aggrs, $cookies, $record) = @_;
58  
59 149 my %ret;
60 149 for my $name (keys(%$aggrs))
61 {
62 197 $ret{$name} = $aggrs->{$name}->combine($cookies->{$name}, $record);
63 }
64  
65 149 return \%ret;
66 }
67  
68 sub map_squish
69 74 ▶{
Subroutine map_squish: called CC=2 SCAR=6.9
Pod undocumented
70 74 my ($aggrs, $cookies) = @_;
71  
72 74 my $return_record = App::RecordStream::Record->new();
73 74 for my $name (keys(%$aggrs))
74 {
75 90 my $aggregator = $aggrs->{$name};
76 90 my $value = $aggregator->squish($cookies->{$name});
77 90 ${$return_record->guess_key_from_spec($name)} = $value;
78 }
79  
80 74 return $return_record;
81 }
82  
83 sub typename
84 20 ▶{
Subroutine typename: called CC=1 SCAR=0.0
Pod undocumented
85 20 return "aggregator";
86 }
87  
88 30 1;
« blib/lib/App/RecordStream/Operation/fromsplit.pm ↑ Summary blib/lib/App/RecordStream/Aggregator/RecordForMaximum.pm »