ZofCMS/Plugin/FileToTemplate.pm

filter: Statementstmt 42.8% 15 / 35 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 3 totaltotal 35.8% 19 / 53 CC 5 SCAR 26.6
CC
5
Cov
35%
callback
30.0
new
2.0
process
2.0
CRAP 14.4
« ZofCMS/Plugin/TagCloud.pm ↑ Summary ZofCMS/Plugin/Doctypes.pm »
1 package App::ZofCMS::Plugin::FileToTemplate;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.001010'; # VERSION
7  
8 1 ▶use Data::Transformer;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub new { bless {}, shift }
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
12  
13 1 my $Template_Dir;
14  
15 0 ▶sub process {
Subroutine process: not called CC=1 SCAR=6.9
Pod undocumented
16 0 my ( $self, $template, $query, $config ) = @_;
17  
18 0 $Template_Dir = $config->conf->{templates};
19  
20 0 my $t = Data::Transformer->new( normal => \&callback );
21 0 $t->traverse( $template );
22 }
23  
24 0 ▶sub callback {
Subroutine callback: not called CC=5 SCAR=34.0
Pod undocumented
25 0 my $in = shift;
26  
27 0 ▶ while ( my ( $t ) = $$in =~ /<FTTR:([^>]+)>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($t) = $$in =~ /<FTTR:([^>]+)>/) 0 0 0
28 0 my $tag_result;
29 0 my $file = File::Spec->catfile( $Template_Dir, $t );
30 0 ▶ if ( open my $fh, '<', $file ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, '<', $file) { } 0 0 0
31 0 $tag_result = do { local $/; <$fh>; };
32 }
33 else {
34 0 $tag_result = $!;
35 }
36 0 $$in =~ s/<FTTR:[^>]+>/$tag_result/;
37 }
38  
39 0 ▶ if ( my ( $t ) = $$in =~ /<FTTD:([^>]+)>/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($t) = $$in =~ /<FTTD:([^>]+)>/) 0 0 0
40 0 my $tag_result;
41 0 my $file = File::Spec->catfile( $Template_Dir, $t );
42  
43 0 ▶ $tag_result = do $file
Branch: 1 branch
BranchTrueFalseTotal
$tag_result = do $file or $tag_result = "ERROR: $! $@" 0 0 0
44 or $tag_result = "ERROR: $! $@";
45  
46 0 $$in = $tag_result;
47 }
48 }
49  
50 1 1;
51 __END__
« ZofCMS/Plugin/TagCloud.pm ↑ Summary ZofCMS/Plugin/Doctypes.pm »