package Template::Coverable; use base qw/Template/; use Template::Coverable::Provider; use Template::Coverable::Document; sub new { my $self = shift; my $tempdir = shift; my $coversubdir = shift; my $config = ( $_[0] ||= {} ); $config->{INCLUDE_PATH} ||= []; $config->{INCLUDE_PATH} = [ $config->{INCLUDE_PATH} ] unless ref($config->{INCLUDE_PATH}) eq 'ARRAY'; push @{ $config->{INCLUDE_PATH} }, $tempdir; my $provider = Template::Coverable::Provider->new( DOCUMENT => 'Template::Coverable::Document', INCLUDE_PATH=> $config->{INCLUDE_PATH}, COMPILE_DIR=> $tempdir . '/' . $coversubdir, COMPILE_EXT=> '.pm', CACHE_SIZE=> 0, ); $config->{LOAD_TEMPLATES} ||= []; $config->{LOAD_TEMPLATES} = [ $config->{LOAD_TEMPLATES} ] unless ref($config->{LOAD_TEMPLATES}) eq 'ARRAY'; push @{ $config->{LOAD_TEMPLATES} }, $provider; return $self->SUPER::new(@_); } sub file2pm { local $_ = shift; s/\.(?!pm$)/___/g; return $_; } sub file2pkg { local $_ = shift; s#^/tmp/__ttc/##; s#^/##; s#/+#::#g; s/\.\w+$//; s/\./___/g; return $_; } 1;