File Coverage

blib/lib/Template/Plugin/DBM/Deep.pm
Criterion Covered Total %
statement 25 26 96.1
branch 6 8 75.0
condition 2 3 66.6
subroutine 6 6 100.0
pod 2 2 100.0
total 41 45 91.1


line stmt bran cond sub pod time code
1             package Template::Plugin::DBM::Deep;
2              
3 2     2   89460 use 5.006;
  2         7  
  2         86  
4 2     2   13 use strict;
  2         4  
  2         75  
5 2     2   12 use warnings;
  2         10  
  2         85  
6              
7 2     2   12 use base qw(Template::Plugin);
  2         3  
  2         1937  
8              
9             our $VERSION = '0.02';
10              
11             sub new {
12 3     3 1 44783 my $class = shift;
13 3         6 my $context = shift; # passed by Template's USE
14              
15 3         7 my %ARGS;
16             ## do we have any named args?
17 3 100 66     23 if (ref $_[-1] and ref $_[-1] eq "HASH") {
18 1         2 %ARGS = %{+pop};
  1         4  
19             };
20             ## do we have any positional args?
21 3 100       13 if (@_) {
22 2         7 $ARGS{"file"} = shift;
23             }
24             ## do we have too many?
25 3 50       11 if (@_) {
26 0         0 die "extra arguments to $class: @_";
27             }
28              
29 3 50       33 die "$class: missing db file" unless $ARGS{"file"};
30              
31             ## now create the DBM::Deep object and return it:
32 3         9 return $class->dbm_deep_class->new(%ARGS);
33             }
34              
35             ## lazy load DBM::Deep, and also return constant
36             ## this permits overriding of the class
37 3     3 1 30 sub dbm_deep_class { require DBM::Deep; "DBM::Deep" }
  3         25  
38              
39             1;
40             __END__