File Coverage

lib/Rex/Box.pm
Criterion Covered Total %
statement 11 26 42.3
branch 0 4 0.0
condition 0 4 0.0
subroutine 4 6 66.6
pod 0 2 0.0
total 15 42 35.7


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Box;
6              
7 1     1   13 use v5.12.5;
  1         3  
8 1     1   6 use warnings;
  1         3  
  1         47  
9              
10             our $VERSION = '1.14.2.2'; # TRIAL VERSION
11              
12 1     1   5 use Rex::Config;
  1         4  
  1         12  
13 1     1   6 use Rex::Logger;
  1         3  
  1         6  
14              
15             my %BOX_PROVIDER;
16              
17             sub register_box_provider {
18 0     0 0   my ( $class, $service_name, $service_class ) = @_;
19 0           $BOX_PROVIDER{"\L$service_name"} = $service_class;
20 0           return 1;
21             }
22              
23             sub create {
24 0     0 0   my ( $class, @opts ) = @_;
25              
26 0   0       my $type = Rex::Config->get("box_type") || "VBox";
27 0   0       my $options = Rex::Config->get("box_options") || {};
28              
29 0           my $klass = "Rex::Box::${type}";
30              
31 0 0         if ( exists $BOX_PROVIDER{$type} ) {
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 0         if ($@) {
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;