File Coverage

blib/lib/App/RecordStream/Aggregator/Average.pm
Criterion Covered Total %
statement 21 23 91.3
branch n/a
condition n/a
subroutine 7 9 77.7
pod 0 3 0.0
total 28 35 80.0


line stmt bran cond sub pod time code
1             package App::RecordStream::Aggregator::Average;
2              
3             our $VERSION = "4.0.25";
4              
5 6     6   64563 use strict;
  6         26  
  6         147  
6 6     6   25 use warnings;
  6         18  
  6         150  
7              
8 6     6   382 use App::RecordStream::Aggregator::Ord2Univariate;
  6         13  
  6         137  
9 6     6   27 use App::RecordStream::Aggregator;
  6         12  
  6         124  
10 6     6   442 use App::RecordStream::DomainLanguage::Registry;
  6         15  
  6         144  
11              
12 6     6   32 use base 'App::RecordStream::Aggregator::Ord2Univariate';
  6         14  
  6         1323  
13              
14             #sub new -- passed through
15              
16             #sub new_from_valuation -- passed through
17              
18             sub squish
19             {
20 2     2 0 18 my ($this, $cookie) = @_;
21              
22 2         7 my ($sum1, $sumx, $sumx2) = @$cookie;
23              
24 2         7 return $sumx / $sum1;
25             }
26              
27             sub long_usage
28             {
29 0     0 0   return <
30             Usage: avg,
31             Average of specified field.
32             EOF
33             }
34              
35             sub short_usage
36             {
37 0     0 0   return "averages provided field";
38             }
39              
40             App::RecordStream::Aggregator->register_implementation('average', __PACKAGE__);
41             App::RecordStream::Aggregator->register_implementation('avg', __PACKAGE__);
42              
43             App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'average', 'VALUATION');
44             App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'avg', 'VALUATION');
45              
46             1;