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

filter: Statementstmt 95.4% 42 / 44 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 12 / 14 Podpod 0.0% 0 / 8 totaltotal 81.8% 54 / 66 CC 1 SCAR 1.3
CC
1
Cov
95%
long_usage
2.0
argct
2.0
BEGIN
1.0
CRAP 1.1
« blib/lib/App/RecordStream/Aggregator/UniqArray.pm ↑ Summary blib/lib/App/RecordStream/Aggregator/DistinctCount.pm »
1 package App::RecordStream::Aggregator::UniqConcatenate;
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;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 ▶use App::RecordStream::DomainLanguage::Registry;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 7 ▶use App::RecordStream::DomainLanguage::Valuation::KeySpec;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 7 ▶use base qw(App::RecordStream::Aggregator::Aggregation);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub new
15 {
16 1 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
17 1 my $delim = shift;
18 1 my $field = shift;
19  
20 1 return new_from_valuation($class, $delim, App::RecordStream::DomainLanguage::Valuation::KeySpec->new($field));
21 }
22  
23 sub new_from_valuation
24 {
25 11 ▶ my $class = shift;
Subroutine new_from_valuation: called CC=1 SCAR=0.0
Pod undocumented
26 11 my $delim = shift;
27 11 my $valuation = shift;
28  
29 11 my $this =
30 {
31 'valuation' => $valuation,
32 'delim' => $delim,
33 };
34  
35 11 bless $this, $class;
36  
37 11 return $this;
38 }
39  
40 sub squish
41 {
42 8 ▶ my ($this, $cookie) = @_;
Subroutine squish: called CC=1 SCAR=0.0
Pod undocumented
43  
44 8 return join($this->{'delim'}, sort(keys(%$cookie)));
45 }
46  
47 sub long_usage
48 {
49 0 ▶ return <<EOF;
Subroutine long_usage: not called CC=1 SCAR=6.9
Pod undocumented
50 Usage: uconcat,<delimiter>,<field>
51 Concatenate unique values from specified field.
52 EOF
53 }
54  
55 sub short_usage
56 {
57 1 ▶ return "concatenate unique values from provided field";
Subroutine short_usage: called CC=1 SCAR=0.0
Pod undocumented
58 }
59  
60 sub argct
61 {
62 0 ▶ return 2;
Subroutine argct: not called CC=1 SCAR=6.9
Pod undocumented
63 }
64  
65 sub initial
66 {
67 8 ▶ return {};
Subroutine initial: called CC=1 SCAR=0.0
Pod undocumented
68 }
69  
70 sub combine
71 {
72 29 ▶ my ($this, $cookie, $record) = @_;
Subroutine combine: called CC=1 SCAR=0.0
Pod undocumented
73  
74 29 my $value = $this->{'valuation'}->evaluate_record($record);
75  
76 29 $cookie->{$value} = 1;
77  
78 29 return $cookie;
79 }
80  
81 7 App::RecordStream::Aggregator->register_implementation('uconcatenate', __PACKAGE__);
82 7 App::RecordStream::Aggregator->register_implementation('uconcat', __PACKAGE__);
83  
84 7 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'uconcatenate', 'SCALAR', 'VALUATION');
85 7 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'uconcat', 'SCALAR', 'VALUATION');
86  
87 7 1;
« blib/lib/App/RecordStream/Aggregator/UniqArray.pm ↑ Summary blib/lib/App/RecordStream/Aggregator/DistinctCount.pm »