blib/lib/App/RecordStream/Operation/tojsonarray.pm

filter: Statementstmt 92.0% 23 / 25 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 4 totaltotal 82.9% 34 / 41 CC 3 SCAR 4.1
CC
3
Cov
93%
accept_line
2.0
stream_done
2.0
usage
2.0
CRAP 1.5
« blib/lib/App/RecordStream/Aggregator/Internal/Constant.pm ↑ Summary blib/lib/App/RecordStream/Accumulator.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package App::RecordStream::Operation::tojsonarray;
6 1 ▶use base qw(App::RecordStream::Operation);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub init {
9 2 ▶ my $this = shift;
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
10 2 my $args = shift;
11 2 $this->parse_options($args);
12 2 $this->{COUNT} = 0;
13 }
14  
15 sub accept_line {
16 4 ▶ my $this = shift;
Subroutine accept_line: called CC=2 SCAR=6.9
Pod undocumented
17 4 my $line = shift;
18 $this->push_line(
19 4 ▶ $this->{COUNT}++ == 0
Branch: 1 branch
BranchTrueFalseTotal
$this->{'COUNT'}++ == 0 ? : 1 3 4
20 ? "[$line"
21 : ",$line"
22 );
23 4 return 1;
24 }
25  
26 sub stream_done {
27 2 ▶ my $this = shift;
Subroutine stream_done: called CC=2 SCAR=6.9
Pod undocumented
28 $this->push_line(
29 $this->{COUNT}
30 2 ▶ ? "]"
Branch: 1 branch
BranchTrueFalseTotal
$this->{'COUNT'} ? : 1 1 2
31 : "[]"
32 );
33 }
34  
35 sub usage {
36 0 ▶ my $this = shift;
Subroutine usage: not called CC=1 SCAR=6.9
Pod undocumented
37 0 return <<USAGE;
38 Usage: recs tojsonarray [files]
39 __FORMAT_TEXT__
40 This command outputs the record stream as a single JSON array. It
41 complements the fromjsonarray command.
42 __FORMAT_TEXT__
43  
44 Examples
45 # Save the record stream to a file suitable for loading by any JSON parser
46 ... | recs tojsonarray > recs.json
47 USAGE
48 }
49  
50 1 1;
« blib/lib/App/RecordStream/Aggregator/Internal/Constant.pm ↑ Summary blib/lib/App/RecordStream/Accumulator.pm »