lib/Rex/Box.pm

filter: Statementstmt 48.2% 14 / 29 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 2 totaltotal 38.3% 18 / 47 CC 5 SCAR 27.5
CC
5
Cov
38%
create
30.0
register_box_provider
2.0
BEGIN
1.0
CRAP 15.6
« lib/Rex/Virtualization/Lxc/create.pm ↑ Summary lib/Rex/Cron.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Box;
6  
7 1 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '1.16.1'; # VERSION
11  
12 1 ▶use Rex::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Rex::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 my %BOX_PROVIDER;
16  
17 0 ▶sub register_box_provider {
Subroutine register_box_provider: not called CC=1 SCAR=6.9
Pod undocumented
18 0 my ( $class, $service_name, $service_class ) = @_;
19 0 $BOX_PROVIDER{"\L$service_name"} = $service_class;
20 0 return 1;
21 }
22  
23 0 ▶sub create {
Subroutine create: not called CC=5 SCAR=34.0
Pod undocumented
24 0 my ( $class, @opts ) = @_;
25  
26 0 ▶ my $type = Rex::Config->get("box_type") || "VBox";
Condition0%0/2
'Rex::Config'->get('box_type') || 'VBox'
l!l
00
MC/DC0%0/1
'Rex::Config'->get('box_type') || 'VBox'
'Rex::Config'->get('box_type')
Truth table0%0/2
A
A= 'Rex::Config'->get('box_type')
Aresult
11
00
27 0 ▶ my $options = Rex::Config->get("box_options") || {};
Condition0%0/2
'Rex::Config'->get('box_options') || {}
l!l
00
MC/DC0%0/1
'Rex::Config'->get('box_options') || {}
'Rex::Config'->get('box_options')
Truth table0%0/2
A
A= 'Rex::Config'->get('box_options')
Aresult
11
00
28  
29 0 my $klass = "Rex::Box::${type}";
30  
31 0 ▶ if ( exists $BOX_PROVIDER{$type} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $BOX_PROVIDER{$type}) 0 0 0
32 0 $klass = $BOX_PROVIDER{$type};
33 }
34  
35 0 Rex::Logger::debug("Using $klass as box provider");
36 0 eval "use $klass;";
37  
38 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
39 0 Rex::Logger::info("Box Class $klass not found.");
40 0 die("Box Class $klass not found.");
41 }
42  
43 0 return $klass->new( @opts, options => $options );
44 }
45  
46 1 1;
« lib/Rex/Virtualization/Lxc/create.pm ↑ Summary lib/Rex/Cron.pm »