File Coverage

blib/lib/Rex/Repositorio/Repository_Factory.pm
Criterion Covered Total %
statement 20 24 83.3
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 27 33 81.8


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring <jan.gehring@gmail.com>
3             #
4             # vim: set ts=2 sw=2 tw=0:
5             # vim: set expandtab:
6              
7             package Rex::Repositorio::Repository_Factory;
8              
9 1     1   1333 use common::sense;
  1         2  
  1         9  
10 1     1   717 use Params::Validate qw(:all);
  1         3189  
  1         310  
11 1     1   5 use English;
  1         2  
  1         6  
12 1     1   286 use Carp;
  1         1  
  1         178  
13              
14             our $VERSION = '1.0.0'; # VERSION
15              
16             sub create {
17 1     1 0 1241 my $class = shift;
18 1         55 my %option = validate(
19             @_,
20             {
21             type => {
22             type => SCALAR
23             },
24             options => {
25             type => HASHREF
26             }
27             }
28             );
29              
30 1         8 my $type = $option{type};
31 1         4 my $repo_mod = "Rex::Repositorio::Repository::$type";
32 1     1   26 eval "use $repo_mod;";
  0         0  
  0         0  
  1         121  
33 1 50       9 if ($EVAL_ERROR) {
34 1         270 confess "Error loading repository type: $type. ($EVAL_ERROR)";
35             }
36              
37 0           return $repo_mod->new( %{ $option{options} } );
  0            
38             }
39              
40             1;