File Coverage

blib/lib/App/Mowyw/Datasource.pm
Criterion Covered Total %
statement 27 31 87.1
branch 4 6 66.6
condition 1 3 33.3
subroutine 7 11 63.6
pod 0 5 0.0
total 39 56 69.6


line stmt bran cond sub pod time code
1             package App::Mowyw::Datasource;
2 14     14   66243 use strict;
  14         26  
  14         481  
3 13     13   58 use warnings;
  13         25  
  13         330  
4 13     13   136 use Carp qw(confess);
  13         23  
  13         4648  
5              
6             our %type_map = (
7             xml => 'XML',
8             dbi => 'DBI',
9             array => 'Array',
10             );
11              
12             sub new {
13 8     8 0 1710 my ($base, $opts) = @_;
14 8 50       49 my $type = lc($opts->{type}) or confess "No 'type' given";
15 8         21 delete $opts->{type};
16 8   33     33 my $type_name = $type_map{$type} || confess "Don't know what to do with datasource type '$type'";
17 8         19 $type_name = "App::Mowyw::Datasource::$type_name";
18 8     3   686 eval "use $type_name;";
  3     2   851  
  3     2   6  
  3         154  
  2         15  
  2         3  
  2         31  
  2         14  
  2         2  
  2         30  
19 8 50       38 confess $@ if $@;
20 8 100       478 my $obj = eval $type_name . "->new(\$opts)" or confess $@;
21 5         36 return $obj;
22             }
23              
24             # these are stubs for inherited classes
25              
26 0     0 0 0 sub reset { confess "Called virtual method in base class!" }
27 0     0 0 0 sub get { confess "Called virtual method in base class!" }
28 0     0 0 0 sub next { confess "Called virtual method in base class!" }
29 0     0 0 0 sub is_exhausted { confess "Called virtual method in base class!" }
30              
31             1;