Virt/Connection/Factory.pm

filter: Statementstmt 56.0% 28 / 50 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 80.0% 8 / 10 Podpod 100% 1 / 1 totaltotal 40.2% 37 / 92 CC 13 SCAR 44.5
CC
13
Cov
37%
create_connection
156.0
_cls_name
3.7
BEGIN
1.0
CRAP 85.8
« Virt/Domain.pm ↑ Summary Virt.pm »
1 ####################################################################
2 #
3 # This file was generated using XDR::Parse version v1.0.1
4 # and LibVirt version v12.9.0
5 #
6 # Don't edit this file, use the source template instead
7 #
8 # ANY CHANGES HERE WILL BE LOST !
9 #
10 ####################################################################
11  
12  
13 1 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Future::AsyncAwait;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Object::Pad;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 class Sys::Async::Virt::Connection::Factory v0.6.9;
20  
21 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Log::Any qw($log);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Protocol::Sys::Virt::URI; # imports 'parse_url'
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 our @default_drivers = (
26 { transport => '', class => 'Local', host => 0 },
27 { transport => 'unix', class => 'Local', host => 0 },
28 { transport => '', class => 'TLS', host => 1 },
29 { transport => 'tls', class => 'TLS' },
30 { transport => 'tcp', class => 'TCP' },
31 { transport => 'ext', class => 'Process' },
32 { transport => 'ssh', class => 'SSH' },
33 );
34  
35 field $_drivers :param = \@default_drivers;
36  
37  
38 # Not documented in the POD: not a method
39 1 ▶sub _cls_name($n) {
Subroutine _cls_name: not called CC=2 SCAR=13.0
40 0 ▶ return ($n =~ s/^\+//)
Branch: 1 branch
BranchTrueFalseTotal
$n =~ s/^\+//u ? : 0 0 0
41 ? $n : "Sys::Async::Virt::Connection::$n";
42 }
43  
44 0 ▶method create_connection( $url, %args ) {
Subroutine create_connection: not called CC=12 SCAR=50.5
Pod documented
45 0 my %components = parse_url( $url );
46 0 ▶ my $transport = $components{transport} // '';
Condition0%0/2
$components{"transport"} // ""
l!l
00
MC/DC0%0/1
$components{"transport"} // ""
$components{"transport"}
Truth table0%0/2
A
A= $components{"transport"}
Aresult
11
00
47 0 ▶ my $host = $components{host} // '';
Condition0%0/2
$components{"host"} // ""
l!l
00
MC/DC0%0/1
$components{"host"} // ""
$components{"host"}
Truth table0%0/2
A
A= $components{"host"}
Aresult
11
00
48  
49 0 for my $driver ($_drivers->@*) {
50 0 ▶ if ($transport eq $driver->{transport}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($transport eq $driver->{"transport"}) 0 0 0
51 0 ▶ if (defined $driver->{host}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $driver->{'host'}) { } 0 0 0
52 0 ▶ if (($driver->{host} and $host)
Branch: 1 branch
BranchTrueFalseTotal
if ($driver->{"host"} and $host or not $driver->{"host"} || $host) 0 0 0
Condition0%0/9
$driver->{"host"} and $host or not $driver->{"host"} || $host
l!l&&r!l&&!r
000
$driver->{"host"} and $host
!ll&&!rl&&r
000
$driver->{'host'} || $host
l!l&&r!l&&!r
000
MC/DC0%0/4
$driver->{"host"} and $host or not $driver->{"host"} || $host
$driver->{"host"} $host $driver->{'host'} $host
Truth table0%0/7
A and B or not(C || D)
A= $driver->{"host"}B= $hostC= $driver->{'host'}D= $host
ABCDresult
11XX1
0X001
10001
0X1X0
0X010
101X0
10010
53 or (not $driver->{host} and not $host)) {
54 0 my $c = _cls_name( $driver->{class} );
55 0 ▶ if (not eval "require $c; 1") {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval "require $c; 1") 0 0 0
56 0 die @!;
57 }
58 0 return $c->new( url => $url, %args );
59 }
60 }
61 else { # "host" not defined, so not required
62 0 my $c = _cls_name( $driver->{class} );
63 0 ▶ if (not eval "require $c; 1") {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval "require $c; 1") 0 0 0
64 0 die @!;
65 }
66 0 return $c->new( url => $url, %args );
67 }
68 }
69 }
70  
71 0 die $log->fatal( "No handler for: $url" );
72 1 }
73  
74 1 1;
75  
76 __END__
« Virt/Domain.pm ↑ Summary Virt.pm »