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

filter: Statementstmt 95.2% 40 / 42 Branchbran 50.0% 6 / 12 Conditioncond 43.7% 7 / 16 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 68.2% 58 / 85 CC 16 SCAR 29.3
CC
16
Cov
76%
execute
23.2
BEGIN
1.0
BEGIN
1.0
CRAP 18.7
« lib/WWW/Hetzner/CLI/Cmd/StorageBox.pm ↑ Summary lib/WWW/Hetzner/Cloud/Costs.pm »
1 package WWW::Hetzner::CLI::Cmd::PrimaryIp::Cmd::Describe;
2 # ABSTRACT: Describe a primary 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 primary-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=16 SCAR=31.4
Pod undocumented
12 1 my ($self, $args, $chain) = @_;
13 1 ▶ my $id = $args->[0] or die "Usage: hcloud.pl primary-ip describe <id>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl primary-ip describe <id>\n" 1 0 1
14  
15 1 my $main = $chain->[0];
16 1 my $cloud = $main->cloud;
17  
18 1 my $pip = $cloud->primary_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($pip->data), "\n";
22 0 return;
23 }
24  
25 1 printf "ID: %s\n", $pip->id;
26 1 ▶ printf "Name: %s\n", $pip->name // '-';
Condition50%1/2
$pip->name // "-"
l!l
10
MC/DC0%0/1
$pip->name // "-"
$pip->name
Truth table50%1/2
A
A= $pip->name
Aresult
11
00
27 1 printf "IP: %s\n", $pip->ip;
28 1 printf "Type: %s\n", $pip->type;
29 1 ▶ printf "Datacenter: %s\n", $pip->datacenter_name // '-';
Condition50%1/2
$pip->datacenter_name // "-"
l!l
10
MC/DC0%0/1
$pip->datacenter_name // "-"
$pip->datacenter_name
Truth table50%1/2
A
A= $pip->datacenter_name
Aresult
11
00
30 1 ▶ printf "Assignee ID: %s\n", $pip->assignee_id // 'not assigned';
Condition50%1/2
$pip->assignee_id // "not assigned"
l!l
10
MC/DC0%0/1
$pip->assignee_id // "not assigned"
$pip->assignee_id
Truth table50%1/2
A
A= $pip->assignee_id
Aresult
11
00
31 1 ▶ printf "Assignee Type:%s\n", $pip->assignee_type // '-';
Condition50%1/2
$pip->assignee_type // "-"
l!l
10
MC/DC0%0/1
$pip->assignee_type // "-"
$pip->assignee_type
Truth table50%1/2
A
A= $pip->assignee_type
Aresult
11
00
32 1 ▶ printf "Auto Delete: %s\n", $pip->auto_delete ? 'yes' : 'no';
Branch: 1 branch
BranchTrueFalseTotal
$pip->auto_delete ? : 1 0 1
33 1 ▶ printf "Blocked: %s\n", $pip->blocked ? 'yes' : 'no';
Branch: 1 branch
BranchTrueFalseTotal
$pip->blocked ? : 0 1 1
34 1 ▶ printf "Created: %s\n", $pip->created // '-';
Condition50%1/2
$pip->created // "-"
l!l
10
MC/DC0%0/1
$pip->created // "-"
$pip->created
Truth table50%1/2
A
A= $pip->created
Aresult
11
00
35  
36 1 my $dns_ptr = $pip->dns_ptr;
37 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
38 1 print "DNS PTR:\n";
39 1 for my $ptr (@$dns_ptr) {
40 1 printf " %s -> %s\n", $ptr->{ip}, $ptr->{dns_ptr};
41 }
42 }
43  
44 1 my $labels = $pip->labels;
45 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
46 1 print "Labels:\n";
47 1 for my $k (sort keys %$labels) {
48 1 printf " %s: %s\n", $k, $labels->{$k};
49 }
50 }
51 }
52  
53 1 1;
54  
55 __END__
« lib/WWW/Hetzner/CLI/Cmd/StorageBox.pm ↑ Summary lib/WWW/Hetzner/Cloud/Costs.pm »