blib/lib/Catmandu/Cmd/count.pm

filter: Statementstmt 91.3% 21 / 23 Branchbran 25.0% 1 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 77.5% 31 / 40 CC 4 SCAR 11.2
CC
4
Cov
77%
command
5.6
BEGIN
1.0
BEGIN
1.0
CRAP 3.1
« blib/lib/Catmandu/Fix/expand_date.pm ↑ Summary blib/lib/Catmandu/Fix/Bind/with.pm »
1 package Catmandu::Cmd::count;
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 1 ▶ (["cql-query|q=s", ""], ["query=s", ""],);
Subroutine command_opt_spec: called CC=1 SCAR=0.0
Pod documented
13 }
14  
15 sub command {
16 1 ▶ my ($self, $opts, $args) = @_;
Subroutine command: called CC=4 SCAR=17.3
Pod documented
17  
18 1 my ($from_args, $from_opts) = $self->_parse_options($args);
19  
20 1 my $from_bag = delete $from_opts->{bag};
21 1 my $from = Catmandu->store($from_args->[0], $from_opts)->bag($from_bag);
22  
23 1 ▶ if ($opts->query // $opts->cql_query) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->query // $opts->cql_query) 0 1 1
Condition33%1/3
$opts->query // $opts->cql_query
l!l&&r!l&&!r
001
MC/DC0%0/2
$opts->query // $opts->cql_query
$opts->query $opts->cql_query
Truth table33%1/3
A // B
A= $opts->queryB= $opts->cql_query
ABresult
1X1
011
000
24 0 ▶ $self->usage_error("Bag isn't searchable")
Branch: 1 branch
BranchTrueFalseTotal
unless $from->can("searcher") 0 0 0
25 unless $from->can('searcher');
26 0 $from = $from->searcher(
27 cql_query => $opts->cql_query,
28 query => $opts->query,
29 );
30 }
31  
32 1 say $from->count;
33 }
34  
35 13 1;
36  
37 __END__
38  
39 =pod
40  
41 =head1 NAME
42  
43 Catmandu::Cmd::count - count the number of objects in a store
44  
45 =head1 EXAMPLES
46  
47 catmandu count <STORE> <OPTIONS>
48  
49 catmandu count ElasticSearch --index-name shop --bag products \
50 --query 'brand:Acme'
51  
52 catmandu help store ElasticSearch
53  
54 =cut
« blib/lib/Catmandu/Fix/expand_date.pm ↑ Summary blib/lib/Catmandu/Fix/Bind/with.pm »