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   1345 use common::sense;
  1         2  
  1         8  
10 1     1   523 use Params::Validate qw(:all);
  1         2574  
  1         259  
11 1     1   9 use English;
  1         2  
  1         9  
12 1     1   636 use Carp;
  1         3  
  1         277  
13              
14             our $VERSION = '0.6.0'; # VERSION
15              
16             sub create {
17 1     1 0 724 my $class = shift;
18 1         40 my %option = validate(
19             @_,
20             {
21             type => {
22             type => SCALAR
23             },
24             options => {
25             type => HASHREF
26             }
27             }
28             );
29              
30 1         5 my $type = $option{type};
31 1         3 my $repo_mod = "Rex::Repositorio::Repository::$type";
32 1     1   17 eval "use $repo_mod;";
  0         0  
  0         0  
  1         78  
33 1 50       6 if ($EVAL_ERROR) {
34 1         189 confess "Error loading repository type: $type. ($EVAL_ERROR)";
35             }
36              
37 0           return $repo_mod->new( %{ $option{options} } );
  0            
38             }
39              
40             1;