blib/lib/App/RecordStream/Operation/multiplex/BaseClumperCallback.pm

filter: Statementstmt 96.0% 49 / 51 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 4 totaltotal 88.7% 63 / 71 CC 4 SCAR 4.9
CC
4
Cov
93%
clumper_callback_begin
3.1
clumper_callback_push_record
2.0
BEGIN
1.0
CRAP 1.6
« blib/lib/App/RecordStream/Clumper/KeyPerfect.pm ↑ Summary blib/lib/App/RecordStream/Operation/sort.pm »
1 package App::RecordStream::Operation::multiplex::BaseClumperCallback;
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::Operation;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use App::RecordStream::Record;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use App::RecordStream::Stream::Sub;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub new {
11 4 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
12 4 my $script = shift;
13 4 my $args = shift;
14 4 my $line_key = shift;
15 4 my $record_cb = shift;
16 4 my $line_cb = shift;
17  
18 4 my $this = {
19 'SCRIPT' => $script,
20 'ARGS' => $args,
21 'LINE_KEY' => $line_key,
22 'RECORD_CB' => $record_cb,
23 'LINE_CB' => $line_cb,
24 };
25 4 bless $this, $class;
26  
27 4 return $this;
28 }
29  
30 sub clumper_callback_begin {
31 8 ▶ my $this = shift;
Subroutine clumper_callback_begin: called CC=3 SCAR=11.3
Pod undocumented
32 8 my $bucket = shift;
33  
34 8 my $record_cb = $this->{'RECORD_CB'};
35 my $record_cb2 = sub {
36 14 ▶ my $r = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
37  
38 14 return $record_cb->(App::RecordStream::Record->new(%$r, %$bucket));
39 8 };
40 8 my $next = App::RecordStream::Stream::Sub->new($record_cb2, $this->{'LINE_CB'});
41 8 my @args = @{$this->{'ARGS'}};
42 8 my $op = App::RecordStream::Operation::create_operation($this->{'SCRIPT'}, \@args, $next);
43  
44 8 ▶ if(@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 0 8 8
45 0 die "Extra options to multiplex operation.";
46 }
47 8 ▶ if(!$op->wants_input()) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($op->wants_input) 0 8 8
48 0 die "Multiplex operation must want input.";
49 }
50  
51 8 return $op;
52 }
53  
54 sub clumper_callback_push_record {
55 32 ▶ my $this = shift;
Subroutine clumper_callback_push_record: called CC=2 SCAR=6.9
Pod undocumented
56 32 my $op = shift;
57 32 my $record = shift;
58  
59 32 my $line_key = $this->{'LINE_KEY'};
60 32 ▶ if(defined($line_key)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $line_key) { } 8 24 32
61 8 $op->accept_line(${$record->guess_key_from_spec($line_key)});
62 }
63 else {
64 24 $op->accept_record($record);
65 }
66 }
67  
68 sub clumper_callback_end {
69 8 ▶ my $this = shift;
Subroutine clumper_callback_end: called CC=1 SCAR=0.0
Pod undocumented
70 8 my $op = shift;
71 8 $op->finish();
72 }
73  
74 2 1;
« blib/lib/App/RecordStream/Clumper/KeyPerfect.pm ↑ Summary blib/lib/App/RecordStream/Operation/sort.pm »