File Coverage

blib/lib/Template/Extract.pm
Criterion Covered Total %
statement 43 43 100.0
branch n/a
condition 1 3 33.3
subroutine 12 12 100.0
pod 4 5 80.0
total 60 63 95.2


line stmt bran cond sub pod time code
1             package Template::Extract;
2             $Template::Extract::VERSION = '0.50';
3 2     2   593079 use strict;
  2         4  
  2         74  
4 2     2   9 use warnings;
  2         5  
  2         175  
5 2     2   35 use 5.006;
  2         11  
6 2     2   9 use constant RUN_CLASS => ( __PACKAGE__ . '::Run' );
  2         5  
  2         149  
7 2     2   8 use constant COMPILE_CLASS => ( __PACKAGE__ . '::Compile' );
  2         5  
  2         85  
8 2     2   8 use constant PARSER_CLASS => ( __PACKAGE__ . '::Parser' );
  2         3  
  2         217  
9              
10             our ( $DEBUG, $EXACT );
11              
12             sub new {
13 14     14 1 7609 my $self = shift;
14 14   33     85 my $class = ref($self) || $self;
15              
16 14         74 my $run_class = $class->RUN_CLASS;
17 14         39 my $compile_class = $class->COMPILE_CLASS;
18 14         36 my $parser_class = $class->PARSER_CLASS;
19              
20 14         34 foreach my $subclass ( $run_class, $compile_class, $parser_class ) {
21             ## no critic
22 2     2   9 no strict 'refs';
  2         3  
  2         654  
23 42         125 $class->load($subclass);
24 42         92 *{"$subclass\::DEBUG"} = *DEBUG;
  42         184  
25 42         69 *{"$subclass\::EXACT"} = *EXACT;
  42         140  
26             }
27              
28             bless(
29             {
30 14         124 run_object => $run_class->new(@_),
31             compile_object => $compile_class->new(@_),
32             parser_object => $parser_class->new(@_),
33             },
34             $class
35             );
36             }
37              
38             sub load {
39 42     42 0 91 my ( $self, $class ) = @_;
40 42         185 $class =~ s{::}{/}g;
41             ## no critic
42 42         3662 require "$class.pm";
43             }
44              
45             sub extract {
46 13     13 1 2734 my $self = shift;
47 13         28 my $template = shift;
48              
49 13         46 $self->run( $self->compile($template), @_ );
50             }
51              
52             sub compile {
53 13     13 1 22 my $self = shift;
54 13         25 my $template = shift;
55 13         79 $self->{compile_object}->compile( $template, $self->{parser_object} );
56             }
57              
58             sub run {
59 13     13 1 1103 my $self = shift;
60 13         79 $self->{run_object}->run(@_);
61             }
62              
63             1;
64              
65             __END__