Catmandu/Cmd/delete.pm

filter: Statementstmt 86.2% 25 / 29 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 78.7% 37 / 47 CC 5 SCAR 13.4
CC
5
Cov
78%
command
7.2
BEGIN
1.0
BEGIN
1.0
CRAP 3.8
« Catmandu/Plugin/Versioning.pm ↑ Summary Catmandu/Cmd.pm »
1 package Catmandu::Cmd::delete;
2  
3 14 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 14 our $VERSION = '1.2025';
6  
7 14 ▶use parent 'Catmandu::Cmd';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 14 ▶use Catmandu;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 14 ▶use Catmandu::Util qw(check_able);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 14 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶sub command_opt_spec {
Subroutine command_opt_spec: called CC=1 SCAR=0.0
Pod documented
13 1 (["cql-query|q=s", ""], ["query=s", ""], ["id=s@", ""],);
14 }
15  
16 1 ▶sub command {
Subroutine command: called CC=5 SCAR=19.7
Pod documented
17 1 my ($self, $opts, $args) = @_;
18  
19 1 my ($from_args, $from_opts) = $self->_parse_options($args);
20  
21 1 my $from_bag = delete $from_opts->{bag};
22 1 my $from = Catmandu->store($from_args->[0], $from_opts)->bag($from_bag);
23 1 ▶ if ($opts->id) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opts->id) { } 0 1 1
elsif ($opts->query // $opts->cql_query) { } 0 1 1
24 0 $from->delete($_) for @{$opts->id};
25 }
26 ▶ elsif ($opts->query // $opts->cql_query) {
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
27 0 check_able($from, 'delete_by_query');
28 0 $from->delete_by_query(
29 cql_query => $opts->cql_query,
30 query => $opts->query,
31 );
32 }
33 else {
34 1 $from->delete_all;
35 }
36  
37 1 $from->commit;
38 }
39  
40 14 1;
41  
42 __END__
« Catmandu/Plugin/Versioning.pm ↑ Summary Catmandu/Cmd.pm »