blib/lib/Catmandu/Cmd/convert.pm

filter: Statementstmt 86.6% 26 / 30 Branchbran 50.0% 5 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 75.4% 40 / 53 CC 7 SCAR 18.3
CC
7
Cov
74%
command
10.0
BEGIN
1.0
BEGIN
1.0
CRAP 6.2
« blib/lib/Catmandu/Fix/Bind/timeout.pm ↑ Summary blib/lib/Catmandu/Interactive.pm »
1 package Catmandu::Cmd::convert;
2  
3 13 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 13 our $VERSION = '1.0201_02';
6  
7 13 ▶use parent 'Catmandu::Cmd';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use Catmandu;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub command_opt_spec {
12 (
13 13 ▶ ["verbose|v", ""],
Subroutine command_opt_spec: called CC=1 SCAR=0.0
Pod documented
14 ["fix=s@", ""],
15 ["var=s%", ""],
16 ["preprocess|pp", ""],
17 ["start=i", ""],
18 ["total=i", ""],
19 );
20 }
21  
22 sub command {
23 9 ▶ my ($self, $opts, $args) = @_;
Subroutine command: called CC=7 SCAR=23.0
Pod documented
24  
25 9 my ($from_args, $from_opts, $into_args, $into_opts)
26 = $self->_parse_options($args);
27  
28 9 my $from = Catmandu->importer($from_args->[0], $from_opts);
29 8 my $into = Catmandu->exporter($into_args->[0], $into_opts);
30  
31 7 ▶ if ($opts->start // $opts->total) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->start // $opts->total) 0 7 7
Condition33%1/3
$opts->start // $opts->total
l!l&&r!l&&!r
007
MC/DC0%0/2
$opts->start // $opts->total
$opts->start $opts->total
Truth table33%1/3
A // B
A= $opts->startB= $opts->total
ABresult
1X1
011
000
32 0 $from = $from->slice($opts->start, $opts->total);
33 }
34 7 ▶ if ($opts->fix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->fix) 4 3 7
35 4 $from = $self->_build_fixer($opts)->fix($from);
36 }
37 4 ▶ if ($opts->verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->verbose) 0 4 4
38 0 $from = $from->benchmark;
39 }
40  
41 4 my $n = $into->add_many($from);
42 3 $into->commit;
43 3 ▶ if ($opts->verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->verbose) 0 3 3
44 0 ▶ say STDERR $n == 1 ? "converted 1 object" : "converted $n objects";
Branch: 1 branch
BranchTrueFalseTotal
$n == 1 ? : 0 0 0
45 0 say STDERR "done";
46 }
47 }
48  
49 13 1;
50  
51 __END__
52  
53 =pod
54  
55 =head1 NAME
56  
57 Catmandu::Cmd::convert - convert objects
58  
59 =head1 EXAMPLES
60  
61 catmandu convert <IMPORTER> <OPTIONS> to <EXPORTER> <OPTIONS>
62  
63 cat books.json | catmandu convert JSON to CSV --fields id,title
64  
65 catmandu help importer JSON
66 catmandu help exporter YAML
67  
68 =cut
« blib/lib/Catmandu/Fix/Bind/timeout.pm ↑ Summary blib/lib/Catmandu/Interactive.pm »