File Coverage

blib/lib/App/RecordStream/Clumper/Key.pm
Criterion Covered Total %
statement 47 47 100.0
branch 2 2 100.0
condition n/a
subroutine 12 12 100.0
pod 0 7 0.0
total 61 68 89.7


line stmt bran cond sub pod time code
1             package App::RecordStream::Clumper::Key;
2              
3 4     4   20 use strict;
  4         5  
  4         82  
4 4     4   14 use warnings;
  4         5  
  4         72  
5              
6 4     4   1380 use App::RecordStream::Clumper::Key::WrappedCallback;
  4         6  
  4         93  
7 4     4   26 use App::RecordStream::Clumper;
  4         5  
  4         70  
8              
9 4     4   17 use base 'App::RecordStream::Clumper';
  4         5  
  4         1239  
10              
11             sub new
12             {
13 7     7 0 19 my $class = shift;
14 7         19 my $field = shift;
15              
16 7         64 return new_from_valuation($class, $field, App::RecordStream::DomainLanguage::Valuation::KeySpec->new($field));
17             }
18              
19             sub new_from_valuation
20             {
21 20     20 0 39 my $class = shift;
22 20         36 my $name = shift;
23 20         33 my $valuation = shift;
24              
25 20         70 my $this =
26             {
27             'name' => $name,
28             'valuation' => $valuation,
29             };
30 20         40 bless $this, $class;
31              
32 20         56 return $this;
33             }
34              
35             sub evaluate_record
36             {
37 161     161 0 204 my $this = shift;
38 161         189 my $record = shift;
39              
40 161         418 my $v = $this->{'valuation'}->evaluate_record($record);
41 161 100       374 if(!defined($v))
42             {
43 2         5 $v = "";
44             }
45              
46 161         278 return $v;
47             }
48              
49             sub clumper_begin
50             {
51 31     31 0 57 my $this = shift;
52 31         49 my $bucket = shift;
53              
54 31         99 return [$bucket, $this->key_clumper_begin()];
55             }
56              
57             sub clumper_push_record
58             {
59 161     161 0 242 my $this = shift;
60 161         209 my $cookie = shift;
61 161         190 my $record = shift;
62 161         186 my $next = shift;
63              
64 161         264 my $name = $this->{'name'};
65 161         300 my $value = $this->evaluate_record($record);
66              
67 161         540 my $wrapped_next = App::RecordStream::Clumper::Key::WrappedCallback->new($next, $cookie->[0], $name, $value);
68              
69 161         432 $this->key_clumper_push_record($cookie->[1], $value, $record, $wrapped_next);
70             }
71              
72             sub clumper_end
73             {
74 31     31 0 43 my $this = shift;
75 31         46 my $cookie = shift;
76 31         58 my $next = shift;
77              
78 31         74 my $wrapped_next = App::RecordStream::Clumper::Key::WrappedCallback->new($next, undef);
79              
80 31         107 $this->key_clumper_end($cookie->[1], $wrapped_next);
81             }
82              
83              
84             sub argct
85             {
86 2     2 0 11 return 1;
87             }
88              
89             1;