OpenInteract2/TT2/Context.pm

filter: Statementstmt 36.6% 11 / 30 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 23.4% 15 / 64 CC 13 SCAR 50.0
CC
13
Cov
21%
template
182.0
BEGIN
1.0
BEGIN
1.0
CRAP 148.1
« OpenInteract2/SPOPS.pm ↑ Summary OpenInteract2/Manage/Website/TestDB.pm »
1 package OpenInteract2::TT2::Context;
2  
3 # $Id: Context.pm,v 1.3 2005/03/18 04:09:51 lachoy Exp $
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use base qw( Template::Context );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Template::Constants qw( STATUS_ERROR ERROR_FILE );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 $OpenInteract2::TT2::Context::VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
10  
11 # Overriding Template::Context so we can get around the issue of the
12 # template name 'x::y' being interpreted as a directive to have a
13 # particular provider parse it (yuck)
14  
15 0 ▶sub template {
Subroutine template: not called CC=13 SCAR=52.0
Pod documented
16 0 my ( $self, $name ) = @_;
17 0 my ( $template );
18  
19 # Template::Document (or sub-class) objects, or CODE refs are
20 # assumed to be pre-compiled templates and are returned intact
21  
22 0 ▶ if ( UNIVERSAL::isa( $name, 'Template::Document' ) || ref( $name ) eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($name, "Template::Document") or ref $name eq "CODE") 0 0 0
Condition0%0/3
UNIVERSAL::isa($name, "Template::Document") or ref $name eq "CODE"
l!l&&r!l&&!r
000
MC/DC0%0/2
UNIVERSAL::isa($name, "Template::Document") or ref $name eq "CODE"
UNIVERSAL::isa($name, "Template::Document") ref $name eq "CODE"
Truth table0%0/3
A or B
A= UNIVERSAL::isa($name, "Template::Document")B= ref $name eq "CODE"
ABresult
1X1
011
000
23 0 return $name;
24 }
25  
26 0 ▶ unless ( ref $name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $name) 0 0 0
27  
28 # we first look in the BLOCKS hash for a BLOCK that may have
29 # been imported from a template (via PROCESS)
30  
31 0 ▶ return $template if ( $template = $self->{ BLOCKS }->{ $name } );
Branch: 1 branch
BranchTrueFalseTotal
if $template = $self->{"BLOCKS"}{$name} 0 0 0
32  
33 # then we iterate through the BLKSTACK list to see if any of the
34 # Template::Documents we're visiting define this BLOCK
35  
36 0 foreach my $blocks (@{ $self->{ BLKSTACK } }) {
37 0 ▶ return $template if ( $blocks && ( $template = $blocks->{ $name } ) );
Branch: 1 branch
BranchTrueFalseTotal
if $blocks and $template = $blocks->{$name} 0 0 0
Condition0%0/3
$blocks and $template = $blocks->{$name}
!ll&&!rl&&r
000
MC/DC0%0/2
$blocks and $template = $blocks->{$name}
$blocks $template = $blocks->{$name}
Truth table0%0/3
A and B
A= $blocksB= $template = $blocks->{$name}
ABresult
0X0
100
111
38 }
39 }
40  
41 0 ▶ my $providers = $self->{ PREFIX_MAP }->{ default } || $self->{ LOAD_TEMPLATES };
Condition0%0/3
$self->{'PREFIX_MAP'}{'default'} || $self->{'LOAD_TEMPLATES'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'PREFIX_MAP'}{'default'} || $self->{'LOAD_TEMPLATES'}
$self->{'PREFIX_MAP'}{'default'} $self->{'LOAD_TEMPLATES'}
Truth table0%0/3
A || B
A= $self->{'PREFIX_MAP'}{'default'}B= $self->{'LOAD_TEMPLATES'}
ABresult
1X1
011
000
42  
43 # Finally we try the regular template providers which will
44 # handle references to files, text, etc., as well as templates
45 # reference by name
46  
47 0 foreach my $provider ( @{ $providers } ) {
48 0 my ( $error );
49 0 ( $template, $error ) = $provider->fetch( $name );
50 0 ▶ return $template unless ( $error );
Branch: 1 branch
BranchTrueFalseTotal
unless $error 0 0 0
51 0 ▶ if ( $error == STATUS_ERROR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error == 255) 0 0 0
52 0 ▶ $self->throw( $template ) if ( ref $template );
Branch: 1 branch
BranchTrueFalseTotal
if ref $template 0 0 0
53 0 $self->throw( ERROR_FILE, $template );
54 }
55 }
56 0 $self->throw( ERROR_FILE, "$name: not found" );
57 }
58  
59 1 1;
60  
61 __END__
« OpenInteract2/SPOPS.pm ↑ Summary OpenInteract2/Manage/Website/TestDB.pm »