lib/WWW/Hetzner/CLI/Role/WaitsForAction.pm

filter: Statementstmt 100% 24 / 24 Branchbran 92.8% 13 / 14 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 87.2% 48 / 55 CC 11 SCAR 19.9
CC
11
Cov
91%
handle_action
10.3
no_wait
2.0
BEGIN
1.0
CRAP 7.3
« lib/WWW/Hetzner/Cloud/API/FloatingIPs.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/UpdateAccessSettings.pm »
1 package WWW::Hetzner::CLI::Role::WaitsForAction;
2 # ABSTRACT: CLI role that waits for a returned Action by default
3  
4 10 our $VERSION = '0.102';
5  
6 10 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use MooX::Options;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 10 option wait => (
12 is => 'ro',
13 default => 1,
14 negativable => 1,
15 doc => 'wait for the action to reach a terminal state before returning',
16 );
17  
18  
19  
20 149 ▶sub no_wait { return $_[0]->wait ? 0 : 1 }
Subroutine no_wait: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]->wait ? : 27 122 149
21  
22  
23 64 ▶sub handle_action {
Subroutine handle_action: called CC=10 SCAR=23.3
Pod documented
24 64 my ($self, $action) = @_;
25 64 ▶ return unless $action;
Branch: 1 branch
BranchTrueFalseTotal
unless $action 1 63 64
26  
27 63 ▶ if (ref $action eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $action eq "ARRAY") 7 56 63
28 7 ▶ return if $self->no_wait;
Branch: 1 branch
BranchTrueFalseTotal
if $self->no_wait 5 2 7
29 2 for my $a (@$action) {
30 4 ▶ $a->wait if blessed($a) && $a->can('wait');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($a) and $a->can("wait") 4 0 4
Condition33%1/3
builtin::blessed($a) and $a->can("wait")
!ll&&!rl&&r
004
MC/DC0%0/2
builtin::blessed($a) and $a->can("wait")
builtin::blessed($a) $a->can("wait")
Truth table33%1/3
A and B
A= builtin::blessed($a)B= $a->can("wait")
ABresult
0X0
100
111
31 }
32 2 return $action;
33 }
34  
35 56 ▶ return unless blessed($action) && $action->can('wait');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($action) and $action->can("wait") 1 55 56
Condition66%2/3
builtin::blessed($action) and $action->can("wait")
!ll&&!rl&&r
1055
MC/DC50%1/2
builtin::blessed($action) and $action->can("wait")
builtin::blessed($action) $action->can("wait")
Truth table66%2/3
A and B
A= builtin::blessed($action)B= $action->can("wait")
ABresult
0X0
100
111
36 55 ▶ return if $self->no_wait;
Branch: 1 branch
BranchTrueFalseTotal
if $self->no_wait 42 13 55
37 13 $action->wait;
38 12 return $action;
39 }
40  
41  
42 10 1;
43  
44 __END__
« lib/WWW/Hetzner/Cloud/API/FloatingIPs.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/UpdateAccessSettings.pm »