blib/lib/Catmandu/Cmd/export.pm

filter: Statementstmt 45.4% 15 / 33 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 83.3% 5 / 6 Podpod 100% 2 / 2 totaltotal 33.8% 22 / 65 CC 10 SCAR 43.0
CC
10
Cov
28%
command
110.0
BEGIN
1.0
BEGIN
1.0
CRAP 73.7
« blib/lib/Catmandu/Cmd/data.pm ↑ Summary blib/lib/Catmandu/Cmd/import.pm »
1 package Catmandu::Cmd::export;
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 1 ▶ ["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 ["limit=i", ""],
19 ["total=i", ""],
20 ["cql-query|q=s", ""],
21 ["query=s", ""],
22 );
23 }
24  
25 sub command {
26 0 ▶ my ($self, $opts, $args) = @_;
Subroutine command: not called CC=10 SCAR=47.0
Pod documented
27  
28 0 my ($from_args, $from_opts, $into_args, $into_opts)
29 = $self->_parse_options($args);
30  
31 0 my $from_bag = delete $from_opts->{bag};
32 0 my $from = Catmandu->store($from_args->[0], $from_opts)->bag($from_bag);
33 0 my $into = Catmandu->exporter($into_args->[0], $into_opts);
34  
35 0 ▶ if ($opts->query // $opts->cql_query) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opts->query // $opts->cql_query) { } 0 0 0
elsif ($opts->start // $opts->total) { } 0 0 0
Condition0%0/3
$opts->query // $opts->cql_query
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts->query // $opts->cql_query
$opts->query $opts->cql_query
Truth table0%0/3
A // B
A= $opts->queryB= $opts->cql_query
ABresult
1X1
011
000
36 0 ▶ $self->usage_error("Bag isn't searchable")
Branch: 1 branch
BranchTrueFalseTotal
unless $from->can("searcher") 0 0 0
37 unless $from->can('searcher');
38 0 $from = $from->searcher(
39 cql_query => $opts->cql_query,
40 query => $opts->query,
41 start => $opts->start,
42 total => $opts->total,
43 limit => $opts->limit,
44 );
45 }
46 ▶ elsif ($opts->start // $opts->total) {
Condition0%0/3
$opts->start // $opts->total
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts->start // $opts->total
$opts->start $opts->total
Truth table0%0/3
A // B
A= $opts->startB= $opts->total
ABresult
1X1
011
000
47 0 $from = $from->slice($opts->start, $opts->total);
48 }
49 0 ▶ if ($opts->fix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->fix) 0 0 0
50 0 $from = $self->_build_fixer($opts)->fix($from);
51 }
52 0 ▶ if ($opts->verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->verbose) 0 0 0
53 0 $from = $from->benchmark;
54 }
55  
56 0 my $n = $into->add_many($from);
57 0 $into->commit;
58 0 ▶ if ($opts->verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->verbose) 0 0 0
59 0 ▶ say STDERR $n == 1 ? "exported 1 object" : "exported $n objects";
Branch: 1 branch
BranchTrueFalseTotal
$n == 1 ? : 0 0 0
60 0 say STDERR "done";
61 }
62 }
63  
64 13 1;
65  
66 __END__
67  
68 =pod
69  
70 =head1 NAME
71  
72 Catmandu::Cmd::export - export objects from a store
73  
74 =head1 EXAMPLES
75  
76 catmandu export <STORE> <OPTIONS> to <EXPORTER> <OPTIONS>
77  
78 catmandu export MongoDB --database-name items --bag book to YAML
79  
80 catmandu help store MongoDB
81 catmandu help exporter YAML
82  
83 =cut
« blib/lib/Catmandu/Cmd/data.pm ↑ Summary blib/lib/Catmandu/Cmd/import.pm »