blib/lib/OPP/Proc/Pivots.pm

filter: Statementstmt 41.3% 12 / 29 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 1 totaltotal 30.6% 15 / 49 CC 9 SCAR 42.2
CC
9
Cov
29%
process
90.0
BEGIN
1.0
BEGIN
1.0
CRAP 67.8
« blib/lib/OPP/Proc/Uniq.pm ↑ Summary blib/lib/OPP/Proc/Dedup.pm »
1 #
2 # $Id: Pivots.pm,v 58d7ce835577 2023/03/25 10:34:10 gomor $
3 #
4 package OPP::Proc::Pivots;
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use base qw(OPP::Proc);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 __PACKAGE__->cgBuildIndices;
10  
11 1 our $VERSION = '1.00';
12  
13 #
14 # NOTE: pivots can handle both SCALAR & ARRAYs for all fields
15 #
16 # | pivots
17 # | pivots domain,subject.organization,subject.email
18 #
19 sub process {
20 0 ▶ my $self = shift;
Subroutine process: not called CC=9 SCAR=45.0
Pod undocumented
21 0 my ($input) = @_;
22  
23 0 my $defaults = [ qw(
24 domain organization geolocus.netname netname subject.organization
25 subject.email issuer.organization
26 app.http.tracker.ga app.http.tracker.gaw app.http.tracker.gpub
27 app.http.tracker.fbq app.http.tracker.snaptr
28 ) ];
29  
30 0 my $rewrite = {
31 'app.extract.domain' => 'domain',
32 };
33  
34 0 my $options = $self->options;
35 0 ▶ my $pivots = defined($options->{0}) ? [ split(',', $options->{0}) ] : $defaults;
Branch: 1 branch
BranchTrueFalseTotal
defined $options->{'0'} ? : 0 0 0
36  
37 0 my %pivots = map { $_ => 1 } @$pivots;
38  
39 0 for my $field (keys %$input) {
40 0 ▶ next unless $pivots{$field};
Branch: 1 branch
BranchTrueFalseTotal
unless $pivots{$field} 0 0 0
41 0 ▶ my $v = $self->value($input, $field) or next;
Branch: 1 branch
BranchTrueFalseTotal
my $v = $self->value($input, $field) or next 0 0 0
42 0 ▶ next unless @$v;
Branch: 1 branch
BranchTrueFalseTotal
unless @$v 0 0 0
43 0 ▶ $field = $rewrite->{$field} || $field;
Condition0%0/3
$rewrite->{$field} || $field
l!l&&r!l&&!r
000
MC/DC0%0/2
$rewrite->{$field} || $field
$rewrite->{$field} $field
Truth table0%0/3
A || B
A= $rewrite->{$field}B= $field
ABresult
1X1
011
000
44 0 for (@$v) {
45 0 ▶ $self->output->add({ $field => $_ }) unless $self->state->exists("$field|$_", $self->idx);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->state->exists("$field|$_", $self->idx) 0 0 0
46 0 $self->state->add("$field|$_", 1, $self->idx);
47 }
48 }
49  
50 0 return 1;
51 }
52  
53 1 1;
54  
55 __END__
« blib/lib/OPP/Proc/Uniq.pm ↑ Summary blib/lib/OPP/Proc/Dedup.pm »