blib/lib/App/RecordStream/Aggregator/CountBy.pm

filter: Statementstmt 93.9% 31 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 81.8% 9 / 11 Podpod 0.0% 0 / 6 totaltotal 80.0% 40 / 50 CC 1 SCAR 1.7
CC
1
Cov
94%
long_usage
2.0
argct
2.0
BEGIN
1.0
CRAP 1.2
« blib/lib/App/RecordStream/Aggregator/Array.pm ↑ Summary blib/lib/App/RecordStream/Aggregator/Records.pm »
1 package App::RecordStream::Aggregator::CountBy;
2  
3 7 our $VERSION = "4.0.23";
4  
5 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 7 ▶use App::RecordStream::Aggregator::InjectInto::Field;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 ▶use App::RecordStream::DomainLanguage::Registry;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 7 ▶use base qw(App::RecordStream::Aggregator::InjectInto::Field);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 #sub new -- passed through
14  
15 #sub new_from_valuation -- passed through
16  
17 sub initial
18 {
19 1 ▶ return {};
Subroutine initial: called CC=1 SCAR=0.0
Pod undocumented
20 }
21  
22 sub combine_field
23 {
24 9 ▶ my $this = shift;
Subroutine combine_field: called CC=1 SCAR=0.0
Pod undocumented
25 9 my $cookie = shift;
26 9 my $value = shift;
27  
28 9 $cookie->{$value}++;
29 9 return $cookie;
30 }
31  
32 sub squish
33 {
34 1 ▶ my $this = shift;
Subroutine squish: called CC=1 SCAR=0.0
Pod undocumented
35 1 my $cookie = shift;
36  
37 1 return $cookie;
38 }
39  
40 sub short_usage
41 {
42 1 ▶ return "counts by unique value for a field";
Subroutine short_usage: called CC=1 SCAR=0.0
Pod undocumented
43 }
44  
45 sub long_usage
46 {
47 0 ▶ return <<EOF;
Subroutine long_usage: not called CC=1 SCAR=6.9
Pod undocumented
48 Usage: cb,<field>
49 Returns a list of uniq values associated with their counts.
50  
51 Unlike most other aggregators, the value of the field returned will actually
52 be a hash, with keys of uniq fields, and values of the counts.
53 EOF
54 }
55  
56 sub argct
57 {
58 0 ▶ return 1;
Subroutine argct: not called CC=1 SCAR=6.9
Pod undocumented
59 }
60  
61 7 App::RecordStream::Aggregator->register_implementation('countby', __PACKAGE__);
62 7 App::RecordStream::Aggregator->register_implementation('cb', __PACKAGE__);
63  
64 7 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'countby', 'VALUATION');
65 7 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'cb', 'VALUATION');
66  
67 7 1;
« blib/lib/App/RecordStream/Aggregator/Array.pm ↑ Summary blib/lib/App/RecordStream/Aggregator/Records.pm »