HiD/Processor/Template.pm

filter: Statementstmt 61.5% 32 / 52 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 81.8% 9 / 11 Podpod 100% 2 / 2 totaltotal 53.7% 43 / 80 CC 7 SCAR 31.7
CC
7
Cov
49%
BUILDARGS
56.0
error
2.0
BEGIN
1.0
CRAP 23.7
« HiD/Generator/TagPages.pm ↑ Summary HiD.pm »
1 # ABSTRACT: Use Template Toolkit to publish your HiD files
2  
3  
4 package HiD::Processor::Template;
5 1 our $AUTHORITY = 'cpan:GENEHACK';
6 1 $HiD::Processor::Template::VERSION = '1.96';
7 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 extends 'HiD::Processor';
9 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use 5.014; # strict, unicode_strings
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use warnings qw/ FATAL utf8 /;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use open qw/ :std :utf8 /;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use charnames qw/ :full /;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 has 'tt' => (
21 is => 'ro' ,
22 isa => 'Template' ,
23 handles => [ qw/ process / ],
24 required => 1 ,
25 );
26  
27 # FIXME this should really probably be a builder on the 'tt' attr
28 # ...which should be called something more generic
29 # ...and which should get args via a second attr that's required
30 sub BUILDARGS {
31 0 ▶ my $class = shift;
Subroutine BUILDARGS: not called CC=7 SCAR=40.3
Pod documented
32  
33 0 ▶ my %args = ( ref $_[0] && ref $_[0] eq 'HASH' ) ? %{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] && ref $_[0] eq 'HASH' ? : 0 0 0
Condition0%0/3
ref $_[0] and ref $_[0] eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_[0] and ref $_[0] eq "HASH"
ref $_[0] ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= ref $_[0]B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
34  
35 # Try to resolve the include path for Template
36 0 my @path = ();
37  
38 # It might be set in the configuration file
39 0 ▶ if(exists $args{INCLUDE_PATH}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"INCLUDE_PATH"}) 0 0 0
40 # Try to evaluate as an array
41 0 my $rc = eval { @path = @{ $args{INCLUDE_PATH} }; 1; };
42 # If that fails, treat as a string and split ':'
43 @path = split /:/, $args{INCLUDE_PATH}
44 0 ▶ if !$rc;
Branch: 1 branch
BranchTrueFalseTotal
unless $rc 0 0 0
45 }
46  
47 # If we got a default 'path' element, append it to the list.
48 0 ▶ if(exists $args{path}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"path"}) 0 0 0
49 # It should be an array
50 0 my $default_path = delete $args{path};
51 0 my $rc = eval { push @path, @{ $default_path }; 1; };
52 # If it's not, split on the ':' in the string
53 0 ▶ push @path, split /:/, $default_path
Branch: 1 branch
BranchTrueFalseTotal
unless $rc 0 0 0
54 if !$rc;
55 }
56  
57 # Finally set the path to the merged path
58 0 $args{INCLUDE_PATH} = \@path;
59  
60 0 return { tt => Template->new( %args ) };
61 }
62  
63  
64 sub error {
65 0 ▶ die $Template::ERROR;
Subroutine error: not called CC=1 SCAR=6.9
Pod documented
66 }
67  
68 1 __PACKAGE__->meta->make_immutable;
69 1 1;
70  
71 __END__
72  
73 =pod
74  
75 =encoding UTF-8
76  
77 =head1 NAME
78  
79 HiD::Processor::Template - Use Template Toolkit to publish your HiD files
80  
81 =head1 SYNOPSIS
82  
83 my $processor = HiD::Proccessor::Template->new({ arg => $val });
84  
85 =head1 DESCRIPTION
86  
87 Wraps up a L<Template> object and allows it to be used during HiD publication.
88  
89 =head1 METHODS
90  
91 =head2 error
92  
93 Display the template error message.
94  
95 =head1 VERSION
96  
97 version 1.96
98  
99 =head1 AUTHOR
100  
101 John SJ Anderson <genehack@genehack.org>
102  
103 =head1 COPYRIGHT AND LICENSE
104  
105 This software is copyright (c) 2015 by John SJ Anderson.
106  
107 This is free software; you can redistribute it and/or modify it under
108 the same terms as the Perl 5 programming language system itself.
109  
110 =cut
« HiD/Generator/TagPages.pm ↑ Summary HiD.pm »