File Coverage

blib/lib/App/RecordStream/Aggregator/UniqArray.pm
Criterion Covered Total %
statement 33 36 91.6
branch n/a
condition n/a
subroutine 11 14 78.5
pod 0 8 0.0
total 44 58 75.8


line stmt bran cond sub pod time code
1             package App::RecordStream::Aggregator::UniqArray;
2              
3             our $VERSION = "4.0.25";
4              
5 6     6   4127 use strict;
  6         13  
  6         172  
6 6     6   32 use warnings;
  6         11  
  6         146  
7              
8 6     6   32 use App::RecordStream::Aggregator;
  6         10  
  6         141  
9 6     6   29 use App::RecordStream::DomainLanguage::Registry;
  6         13  
  6         124  
10 6     6   29 use App::RecordStream::DomainLanguage::Valuation::KeySpec;
  6         26  
  6         150  
11              
12 6     6   36 use base qw(App::RecordStream::Aggregator::Aggregation);
  6         12  
  6         2135  
13              
14             sub new {
15 1     1 0 2 my $class = shift;
16 1         2 my $field = shift;
17              
18 1         3 return new_from_valuation($class, App::RecordStream::DomainLanguage::Valuation::KeySpec->new($field));
19             }
20              
21             sub new_from_valuation {
22 10     10 0 21 my $class = shift;
23 10         13 my $valuation = shift;
24              
25 10         29 my $this =
26             {
27             'valuation' => $valuation,
28             };
29              
30 10         20 bless $this, $class;
31              
32 10         27 return $this;
33             }
34              
35             sub squish {
36 4     4 0 11 my ($this, $cookie) = @_;
37              
38 4         33 return [ sort keys %$cookie ];
39             }
40              
41             sub long_usage {
42 0     0 0 0 return <
43             Usage: uarray,
44             Collect unique values from specified field into an array.
45             EOF
46             }
47              
48             sub short_usage {
49 0     0 0 0 return "collect unique values from provided field into an array";
50             }
51              
52             sub argct {
53 0     0 0 0 return 1;
54             }
55              
56             sub initial {
57 4     4 0 10 return {};
58             }
59              
60             sub combine {
61 16     16 0 30 my ($this, $cookie, $record) = @_;
62              
63 16         49 my $value = $this->{'valuation'}->evaluate_record($record);
64              
65 16         43 $cookie->{$value} = 1;
66              
67 16         66 return $cookie;
68             }
69              
70             App::RecordStream::Aggregator->register_implementation('uarray', __PACKAGE__);
71              
72             App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'uarray', 'VALUATION');
73              
74             1;