blib/lib/App/RecordStream/Deaggregator/Unhash.pm

filter: Statementstmt 82.3% 42 / 51 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 10 / 12 Podpod 0.0% 0 / 6 totaltotal 76.0% 54 / 71 CC 3 SCAR 4.5
CC
3
Cov
83%
deaggregate_field
3.0
new_from_valuation
2.0
long_usage
2.0
CRAP 1.6
« blib/lib/App/RecordStream/Aggregator/Mode.pm ↑ Summary blib/lib/App/RecordStream/OptionalRequire.pm »
1 package App::RecordStream::Deaggregator::Unhash;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use App::RecordStream::Deaggregator::Field;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use App::RecordStream::Deaggregator;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use App::RecordStream::DomainLanguage::Registry;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use base 'App::RecordStream::Deaggregator::Field';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub new
13 {
14 2 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
15 2 my $old_field = shift;
16 2 my $new_key_field = shift;
17 2 my $new_value_field = shift;
18  
19 2 my $this = $class->SUPER::new($old_field);
20  
21 2 $this->{'new_key_field'} = $new_key_field;
22 2 $this->{'new_value_field'} = $new_value_field;
23  
24 2 return $this;
25 }
26  
27 sub new_from_valuation
28 {
29 0 ▶ my $class = shift;
Subroutine new_from_valuation: not called CC=1 SCAR=6.9
Pod undocumented
30 0 my $valuation = shift;
31 0 my $new_key_field = shift;
32 0 my $new_value_field = shift;
33  
34 0 my $this = $class->SUPER::new_from_valuation($valuation);
35  
36 0 $this->{'new_key_field'} = $new_key_field;
37 0 $this->{'new_value_field'} = $new_value_field;
38  
39 0 return $this;
40 }
41  
42 sub deaggregate_field
43 {
44 2 ▶ my $this = shift;
Subroutine deaggregate_field: called CC=3 SCAR=11.0
Pod undocumented
45 2 my $hashref = shift;
46  
47 2 my @ret;
48  
49 2 for my $key (sort(keys(%$hashref)))
50 {
51 4 my $record = {};
52 4 $record->{$this->{'new_key_field'}} = $key;
53 4 ▶ if(defined($this->{'new_value_field'}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $this->{"new_value_field"}) 2 2 4
54 {
55 2 $record->{$this->{'new_value_field'}} = $hashref->{$key};
56 }
57 4 push @ret, $record;
58 }
59  
60 2 return \@ret;
61 }
62  
63 sub long_usage
64 {
65 0 ▶ return <<EOF;
Subroutine long_usage: not called CC=1 SCAR=6.9
Pod undocumented
66 Usage: unhash,<old field>,<new key field>[,<new value field>]
67 Split the hash into key/value \"pair\" records
68 EOF
69 }
70  
71 sub short_usage
72 {
73 1 ▶ return "split the provided hash";
Subroutine short_usage: called CC=1 SCAR=0.0
Pod undocumented
74 }
75  
76 sub argct
77 {
78 2 ▶ return [2, 3];
Subroutine argct: called CC=1 SCAR=0.0
Pod undocumented
79 }
80  
81 2 App::RecordStream::Deaggregator->register_implementation('unhash', __PACKAGE__);
82  
83 2 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'unhash', 'VALUATION', 'SCALAR');
84 2 App::RecordStream::DomainLanguage::Registry::register_vfn(__PACKAGE__, 'new_from_valuation', 'unhash', 'VALUATION', 'SCALAR', 'SCALAR');
85  
86 2 1;
« blib/lib/App/RecordStream/Aggregator/Mode.pm ↑ Summary blib/lib/App/RecordStream/OptionalRequire.pm »