Embra/Plugin/TemplateToolkit.pm

filter: Statementstmt 96.8% 62 / 64 Branchbran 62.5% 10 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 89.4% 17 / 19 Podpod n/a totaltotal 89.9% 89 / 99 CC 10 SCAR 7.7
CC
10
Cov
90%
exclude_file
4.0
assemble_files
4.0
__ANON__
2.1
CRAP 2.2
« Embra/Plugin/SnippetsToNotes.pm ↑ Summary Embra/Plugin/DetectYamlFrontMatter.pm »
1 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package App::Embra::Plugin::TemplateToolkit;
5 2 $App::Embra::Plugin::TemplateToolkit::VERSION = '0.001'; # TRIAL
6 # ABSTRACT: use Template::Toolkit to turn file content into HTML
7  
8 2 ▶use Path::Class qw<>;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Method::Signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14  
15 has 'include_path' => (
16 is => 'ro',
17 0 ▶ default => sub { 'templates' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 2 ▶ coerce => sub { Path::Class::dir( $_[0] ) },
Subroutine __ANON__: called CC=1 SCAR=0.0
19 2 );
20  
21  
22 1 ▶has 'default_template' => (
Subroutine __ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 1 1
23 2 is => 'lazy',
24 default => method { 'default'. $self->extension },
25 );
26  
27  
28 2 ▶has 'extension' => (
Subroutine __ANON__: called CC=1 SCAR=0.0
29 2 is => 'ro',
30 default => sub { '.tt' },
31 );
32 2  
33  
34 has 'assembler' => (
35 is => 'lazy',
36 2 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _build_assembler: called CC=2 SCAR=7.0
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 1 1
37 1  
38 method _build_assembler {
39 Template->new({
40 INCLUDE_PATH => $self->include_path,
41 DEFAULT => $self->default_template,
42 TRIM => 1,
43 });
44 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine assemble_files: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 2 2
45 2  
46 3 ▶method assemble_files {
Branch: 1 branch
BranchTrueFalseTotal
if $file->ext ne "html" 1 2 3
47 for my $file ( @{ $self->embra->files } ) {
48 2 next if $file->ext ne 'html';
49 2  
50 my $template = $file->with_ext( $self->extension );
51 my $assembled;
52 my $notes = {
53 2 content => $file->content,
54 name => $file->name,
55 2 ▶ %{ $file->notes },
Subroutine BEGIN: called CC=1 SCAR=0.0
56 2 ▶ };
Subroutine __ANON__: called CC=2 SCAR=7.6
57 2 ▶ use Try::Tiny;
Branch: 1 branch
BranchTrueFalseTotal
$self->assembler->process($template, $notes, \$assembled) or $self->debug($self->assembler->error) 2 0 2
58 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
59 0 $self->assembler->process( $template, $notes, \$assembled ) or $self->debug( $self->assembler->error );
60 2 } catch {
61 2 $self->debug( $_ );
62 2 };
63 $file->content( $assembled );
64 $file->notes->{assembled_by} = __PACKAGE__;
65 }
66 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.1
Subroutine exclude_file: called CC=4 SCAR=14.0
Branch: 2 branches
BranchTrueFalseTotal
unless scalar @_ > 0 0 3 3
if scalar @_ > 1 0 3 3
67 3 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if $self->include_path->subsumes($file->name) 1 2 3
68 2 method exclude_file( $file ) {
69 return 1 if $self->include_path->subsumes( $file->name );
70 return;
71 2 }
72 2  
73 with 'App::Embra::Role::FileAssembler';
74 2 with 'App::Embra::Role::FilePruner';
75  
76 1;
77  
78 __END__
« Embra/Plugin/SnippetsToNotes.pm ↑ Summary Embra/Plugin/DetectYamlFrontMatter.pm »