blib/lib/Shipwright/Script/Delete.pm

filter: Statementstmt 39.5% 17 / 43 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 2 totaltotal 26.5% 22 / 83 CC 15 SCAR 51.5
CC
15
Cov
25%
run
240.0
options
2.0
BEGIN
1.0
CRAP 171.8
« blib/lib/Shipwright/Backend/SVK.pm ↑ Summary blib/lib/Shipwright/Backend/SVN.pm »
1 package Shipwright::Script::Delete;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use base qw/App::CLI::Command Shipwright::Base Shipwright::Script/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 __PACKAGE__->mk_accessors(qw/unreferenced check_only/);
8  
9 1 ▶use Shipwright;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Shipwright::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 0 ▶sub options {
Subroutine options: not called CC=1 SCAR=6.9
Pod undocumented
13 (
14 0 'unreferenced' => 'unreferenced',
15 'C|check-only' => 'check_only',
16 );
17 }
18  
19 0 ▶sub run {
Subroutine run: not called CC=15 SCAR=54.8
Pod undocumented
20 0 my $self = shift;
21 0 my @sources = @_;
22  
23 0 ▶ unless ( @sources || $self->unreferenced ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@sources or $self->unreferenced) 0 0 0
Condition0%0/3
@sources or $self->unreferenced
l!l&&r!l&&!r
000
MC/DC0%0/2
@sources or $self->unreferenced
@sources $self->unreferenced
Truth table0%0/3
A or B
A= @sourcesB= $self->unreferenced
ABresult
1X1
011
000
24 0 confess_or_die "need name arg or --unreferenced\n";
25 }
26  
27 0 ▶ if ( @sources && $self->unreferenced ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@sources and $self->unreferenced) 0 0 0
Condition0%0/3
@sources and $self->unreferenced
!ll&&!rl&&r
000
MC/DC0%0/2
@sources and $self->unreferenced
@sources $self->unreferenced
Truth table0%0/3
A and B
A= @sourcesB= $self->unreferenced
ABresult
0X0
100
111
28 0 confess_or_die "please choose only one thing: a dist name or --unreferenced";
29 }
30  
31 0 my $shipwright = Shipwright->new( repository => $self->repository, );
32 0 my @names;
33  
34 0 ▶ if (@sources) {
Branch: 1 branch
BranchTrueFalseTotal
if (@sources) { } 0 0 0
35 0 for my $name (@sources) {
36 0 my $map = $shipwright->backend->map;
37 0 ▶ if ( $map && $map->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($map and $map->{$name}) 0 0 0
Condition0%0/3
$map and $map->{$name}
!ll&&!rl&&r
000
MC/DC0%0/2
$map and $map->{$name}
$map $map->{$name}
Truth table0%0/3
A and B
A= $mapB= $map->{$name}
ABresult
0X0
100
111
38  
39 # it's a cpan module
40 0 $name = $map->{$name};
41 }
42 0 push @names, $name;
43 }
44 }
45 else {
46  
47 # unreferenced dists except the last one
48 0 my $refs = $shipwright->backend->refs;
49 0 my $order = $shipwright->backend->order;
50 0 ▶ if ($refs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($refs) 0 0 0
51 0 for my $name ( keys %$refs ) {
52 0 ▶ next if $name eq $order->[-1];
Branch: 1 branch
BranchTrueFalseTotal
if $name eq $order->[-1] 0 0 0
53 0 ▶ push @names, $name unless $refs->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless $refs->{$name} 0 0 0
54 }
55 }
56 }
57  
58 0 ▶ if ( $self->check_only ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->check_only) { } 0 0 0
59 0 $self->log->fatal( "dists to be deleted are: @names" );
60 }
61 else {
62 0 for my $name (@names) {
63 0 $shipwright->backend->trim( name => $name );
64 }
65 0 $self->log->fatal( "successfully deleted @names" );
66 }
67  
68 }
69  
70 1 1;
71  
72 __END__
« blib/lib/Shipwright/Backend/SVK.pm ↑ Summary blib/lib/Shipwright/Backend/SVN.pm »