File Coverage

blib/lib/StaticVolt/Convertor.pm
Criterion Covered Total %
statement 18 19 94.7
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 3 3 100.0
total 28 30 93.3


line stmt bran cond sub pod time code
1             # ABSTRACT: Base class for StaticVolt convertors
2              
3             package StaticVolt::Convertor;
4             {
5             $StaticVolt::Convertor::VERSION = '1.00';
6             }
7              
8 4     4   22 use strict;
  4         7  
  4         128  
9 4     4   21 use warnings;
  4         5  
  4         348  
10              
11             my %convertor;
12              
13             sub has_convertor {
14 4     4 1 11 my ( $self, $extension ) = @_;
15              
16 4 50       19 if ( exists $convertor{$extension} ) {
17 4         26 return 1;
18             }
19 0         0 return;
20             }
21              
22             sub convert {
23 4     4 1 12 my ( $self, $content, $extension ) = @_;
24              
25 4     4   19 no strict 'refs';
  4         14  
  4         559  
26 4         10 return &{"${convertor{$extension}}::convert"}($content);
  4         48  
27             }
28              
29             sub register {
30 8     8 1 32 my ( $class, @extensions ) = @_;
31              
32 8         24 for my $extension (@extensions) {
33 16         67 $convertor{$extension} = $class;
34             }
35             }
36              
37             1;
38              
39             __END__