blib/lib/Dancer/Template/Mason2.pm

filter: Statementstmt 83.3% 35 / 42 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 4 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 75.0% 9 / 12 Podpod 100% 5 / 5 totaltotal 68.3% 54 / 79 CC 7 SCAR 13.5
CC
7
Cov
71%
init
7.6
view
6.0
default_tmpl_ext
2.0
CRAP 3.9
↑ Summary
1 package Dancer::Template::Mason2;
2 2 $Dancer::Template::Mason2::VERSION = '0.05';
3 2 ▶use Dancer::Config 'setting';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use FindBin;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Mason;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use base 'Dancer::Template::Abstract';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 my $_engine;
12 my $root_dir;
13  
14 1 ▶sub init {
Subroutine init: called CC=6 SCAR=20.3
Pod documented
15 1 my $self = shift;
16 1 ▶ my $config = $self->config || {};
Condition50%1/2
$self->config || {}
l!l
10
MC/DC0%0/1
$self->config || {}
$self->config
Truth table50%1/2
A
A= $self->config
Aresult
11
00
17  
18 1 ▶ $root_dir = $config->{comp_root} ||= setting('views') || $FindBin::Bin . '/views';
Condition40%2/5
$config->{"comp_root"} ||= setting("views") || $FindBin::Bin . '/views'
l!l&&r!l&&!r
010
setting('views') || $FindBin::Bin . '/views'
l!l
01
MC/DC0%0/2
$config->{"comp_root"} ||= setting("views") || $FindBin::Bin . '/views'
$config->{"comp_root"} setting('views')
Truth table0%0/3
A ||= B
A= $config->{"comp_root"}B= setting('views')
ABresult
1X1
011
000
19 1 ▶ $config->{data_dir} ||= dirname($root_dir) . "/data";
Condition50%1/2
$config->{"data_dir"} ||= dirname($root_dir) . '/data'
l!l
01
MC/DC0%0/1
$config->{"data_dir"} ||= dirname($root_dir) . '/data'
$config->{"data_dir"}
Truth table50%1/2
A
A= $config->{"data_dir"}
Aresult
11
00
20 1 ▶ $config->{autoextend_request_path} = 0 if !exists( $config->{autoextend_request_path} );
Branch: 1 branch
BranchTrueFalseTotal
unless exists $config->{"autoextend_request_path"} 1 0 1
21  
22 1 $_engine = Mason->new(%$config);
23 }
24  
25 0 ▶sub default_tmpl_ext { "mc" }
Subroutine default_tmpl_ext: not called CC=1 SCAR=6.9
Pod documented
26  
27 1 ▶sub render {
Subroutine render: called CC=1 SCAR=0.0
Pod documented
28 1 my ( $self, $template, $tokens ) = @_;
29  
30 1 $template =~ s/^\Q$root_dir//; # cut the leading path
31 1 $template =~ y|\\|/|; # convert slashes on Windows
32  
33 1 my $content = $_engine->run( $template, %$tokens )->output;
34 1 return $content;
35 }
36  
37 0 ▶sub view {
Subroutine view: not called CC=2 SCAR=17.9
Pod documented
38 0 my ( $self, $view ) = @_;
39  
40 0 my $views_dir = Dancer::App->current->setting('views');
41 0 ▶ my $tmpl_ext = $self->config->{extension} || $self->default_tmpl_ext();
Condition0%0/3
$self->config->{'extension'} || $self->default_tmpl_ext
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->config->{'extension'} || $self->default_tmpl_ext
$self->config->{'extension'} $self->default_tmpl_ext
Truth table0%0/3
A || B
A= $self->config->{'extension'}B= $self->default_tmpl_ext
ABresult
1X1
011
000
42 0 my $view_path = sprintf( '%s/%s.%s', $views_dir, $view, $self->default_tmpl_ext );
43 0 return $view_path;
44 }
45  
46 0 ▶sub view_exists { return 1; }
Subroutine view_exists: not called CC=1 SCAR=6.9
Pod documented
47  
48 2 1;
49  
50 __END__
↑ Summary