lib/WWW/Hetzner/CLI/Cmd/FloatingIp/Cmd/Describe.pm

filter: Statementstmt 95.1% 39 / 41 Branchbran 50.0% 5 / 10 Conditioncond 43.7% 7 / 16 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 68.2% 56 / 82 CC 15 SCAR 28.3
CC
15
Cov
76%
execute
21.2
BEGIN
1.0
BEGIN
1.0
CRAP 16.9
« lib/WWW/Hetzner/CLI/Cmd/Costs.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Describe.pm »
1 package WWW::Hetzner::CLI::Cmd::FloatingIp::Cmd::Describe;
2 # ABSTRACT: Describe a floating IP
3  
4 1 our $VERSION = '0.102';
5  
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use MooX::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl floating-ip describe <id>';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use JSON::MaybeXS qw(encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶sub execute {
Subroutine execute: called CC=15 SCAR=30.5
Pod undocumented
12 1 my ($self, $args, $chain) = @_;
13 1 ▶ my $id = $args->[0] or die "Usage: hcloud.pl floating-ip describe <id>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl floating-ip describe <id>\n" 1 0 1
14  
15 1 my $main = $chain->[0];
16 1 my $cloud = $main->cloud;
17  
18 1 my $fip = $cloud->floating_ips->get($id);
19  
20 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
21 0 print encode_json($fip->data), "\n";
22 0 return;
23 }
24  
25 1 printf "ID: %s\n", $fip->id;
26 1 ▶ printf "Name: %s\n", $fip->name // '-';
Condition50%1/2
$fip->name // "-"
l!l
10
MC/DC0%0/1
$fip->name // "-"
$fip->name
Truth table50%1/2
A
A= $fip->name
Aresult
11
00
27 1 ▶ printf "Description: %s\n", $fip->description // '-';
Condition50%1/2
$fip->description // "-"
l!l
10
MC/DC0%0/1
$fip->description // "-"
$fip->description
Truth table50%1/2
A
A= $fip->description
Aresult
11
00
28 1 printf "IP: %s\n", $fip->ip;
29 1 printf "Type: %s\n", $fip->type;
30 1 ▶ printf "Location: %s\n", $fip->location // '-';
Condition50%1/2
$fip->location // "-"
l!l
10
MC/DC0%0/1
$fip->location // "-"
$fip->location
Truth table50%1/2
A
A= $fip->location
Aresult
11
00
31 1 ▶ printf "Server: %s\n", $fip->server // 'not assigned';
Condition50%1/2
$fip->server // "not assigned"
l!l
10
MC/DC0%0/1
$fip->server // "not assigned"
$fip->server
Truth table50%1/2
A
A= $fip->server
Aresult
11
00
32 1 ▶ printf "Blocked: %s\n", $fip->blocked ? 'yes' : 'no';
Branch: 1 branch
BranchTrueFalseTotal
$fip->blocked ? : 0 1 1
33 1 ▶ printf "Created: %s\n", $fip->created // '-';
Condition50%1/2
$fip->created // "-"
l!l
10
MC/DC0%0/1
$fip->created // "-"
$fip->created
Truth table50%1/2
A
A= $fip->created
Aresult
11
00
34  
35 1 my $dns_ptr = $fip->dns_ptr;
36 1 ▶ if ($dns_ptr && @$dns_ptr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dns_ptr and @$dns_ptr) 1 0 1
Condition33%1/3
$dns_ptr and @$dns_ptr
!ll&&!rl&&r
001
MC/DC0%0/2
$dns_ptr and @$dns_ptr
$dns_ptr @$dns_ptr
Truth table33%1/3
A and B
A= $dns_ptrB= @$dns_ptr
ABresult
0X0
100
111
37 1 print "DNS PTR:\n";
38 1 for my $ptr (@$dns_ptr) {
39 1 printf " %s -> %s\n", $ptr->{ip}, $ptr->{dns_ptr};
40 }
41 }
42  
43 1 my $labels = $fip->labels;
44 1 ▶ if ($labels && %$labels) {
Branch: 1 branch
BranchTrueFalseTotal
if ($labels and %$labels) 1 0 1
Condition33%1/3
$labels and %$labels
!ll&&!rl&&r
001
MC/DC0%0/2
$labels and %$labels
$labels %$labels
Truth table33%1/3
A and B
A= $labelsB= %$labels
ABresult
0X0
100
111
45 1 print "Labels:\n";
46 1 for my $k (sort keys %$labels) {
47 1 printf " %s: %s\n", $k, $labels->{$k};
48 }
49 }
50 }
51  
52 1 1;
53  
54 __END__
« lib/WWW/Hetzner/CLI/Cmd/Costs.pm ↑ Summary lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Describe.pm »