blib/lib/Text/MicroMason/CompileCache.pm

filter: Statementstmt 100% 18 / 18 Branchbran 66.6% 4 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 85.2% 29 / 34 CC 5 SCAR 9.4
CC
5
Cov
89%
_compile_cache
3.1
compile
3.0
BEGIN
1.0
CRAP 2.6
« blib/lib/Text/MicroMason/PLP.pm ↑ Summary blib/lib/Text/MicroMason/Embperl.pm »
1 package Text::MicroMason::CompileCache;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 require Text::MicroMason::Cache::Simple;
7 4 require Text::MicroMason::Cache::File;
8  
9 ######################################################################
10 # What cache class should we use for each src_type?
11  
12 4 my %CACHE_CLASS = (
13 file => 'Text::MicroMason::Cache::File',
14 text => 'Text::MicroMason::Cache::Simple',
15 );
16  
17 ######################################################################
18  
19 # $code_ref = compile( file => $filename );
20 64 ▶sub compile {
Subroutine compile: called CC=3 SCAR=11.0
Pod documented
21 64 my $self = shift;
22 64 my ( $src_type, $src_data, %options ) = @_;
23 64 ▶ my $cache = $self->_compile_cache( $src_type )
Branch: 1 branch
BranchTrueFalseTotal
my $cache = $self->_compile_cache($src_type) or return $self->NEXT("compile", @_) 64 0 64
24 or return $self->NEXT('compile', @_);
25 64 my $key = $self->cache_key(@_);
26 64 ▶ $cache->get( $key ) or $cache->set( $key,
Branch: 1 branch
BranchTrueFalseTotal
$cache->get($key) or $cache->set($key, $self->NEXT("compile", @_)) 46 18 64
27 $self->NEXT('compile', @_),
28 );
29 }
30  
31 64 ▶sub _compile_cache {
Subroutine _compile_cache: called CC=3 SCAR=11.4
32 64 my ($self, $type) = @_;
33 64 ▶ $CACHE_CLASS{$type} or return;
Branch: 1 branch
BranchTrueFalseTotal
$CACHE_CLASS{$type} or return 64 0 64
34
35 64 ▶ $self->{compile_cache}{$type} ||= $CACHE_CLASS{$type}->new();
Condition66%2/3
$self->{"compile_cache"}{$type} ||= $CACHE_CLASS{$type}->new
l!l&&r!l&&!r
50140
MC/DC0%0/2
$self->{"compile_cache"}{$type} ||= $CACHE_CLASS{$type}->new
$self->{"compile_cache"}{$type} $CACHE_CLASS{$type}->new
Truth table66%2/3
A ||= B
A= $self->{"compile_cache"}{$type}B= $CACHE_CLASS{$type}->new
ABresult
1X1
011
000
36 }
37  
38 ######################################################################
39  
40  
41 4 1;
42  
43 __END__
« blib/lib/Text/MicroMason/PLP.pm ↑ Summary blib/lib/Text/MicroMason/Embperl.pm »