HiD/Processor/IIBlog.pm untested

filter: Statementstmt 0.0% 0 / 49 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 70 CC 3 SCAR 14.2
CC
3
Cov
0%
BUILDARGS
12.0
process
2.0
BEGIN
2.0
CRAP 4.1
1 # ABSTRACT: The modified form of HiD::Proccessor::Handlebars we use to publish II's blog
2  
3  
4 package HiD::Processor::IIBlog;
5 $HiD::Processor::IIBlog::VERSION = '1.5';
6 use Moose;
7 extends 'HiD::Processor';
8 use namespace::autoclean;
9  
10 use 5.014;
11 use utf8;
12 use autodie;
13 use warnings qw/ FATAL utf8 /;
14 use open qw/ :std :utf8 /;
15 use charnames qw/ :full /;
16 use feature qw/ unicode_strings /;
17  
18 use Text::Xslate;
19  
20 has 'txs' => (
21 is => 'ro' ,
22 isa => 'Text::Xslate' ,
23 required => 1 ,
24 );
25  
26 # FIXME this should really probably be a builder on the 'tt' attr
27 # ...which should be called something more generic
28 # ...and which should get args via a second attr that's required
29 sub BUILDARGS {
30 my $class = shift;
31  
32 my %args = ( ref $_[0] && ref $_[0] eq 'HASH' ) ? %{ $_[0] } : @_;
33  
34 my $path = [ '.' , './_layouts' ];
35 push @$path , './_includes' if -e -d './_includes';
36  
37 return {
38 txs => Text::Xslate->new(
39 function => {
40 commafy => sub { my $a = shift; join ',' , @$a },
41 lc => sub { lc( shift ) } ,
42 pretty_date => sub { shift->strftime( "%d %b %Y" ) },
43 } ,
44 path => $path ,
45 ),
46 };
47 }
48  
49 sub process {
50 my( $self , $input_ref , $args , $output_ref ) = @_;
51  
52 $$output_ref = $self->txs->render_string( $$input_ref , $args );
53  
54 return 1;
55 }
56  
57 __PACKAGE__->meta->make_immutable;
58 1;
59  
60 __END__
61  
62 =pod
63  
64 =encoding utf-8
65  
66 =head1 NAME
67  
68 HiD::Processor::IIBlog - The modified form of HiD::Proccessor::Handlebars we use to publish II's blog
69  
70 =head1 SYNOPSIS
71  
72 my $processor = HiD::Proccessor::IIBlog->new({ arg => $val });
73  
74 =head1 DESCRIPTION
75  
76 Wraps up a L<Text::Xslate> object and allows it to be used during HiD
77 publication.
78  
79 =head1 VERSION
80  
81 version 1.5
82  
83 =head1 AUTHOR
84  
85 John SJ Anderson <genehack@genehack.org>
86  
87 =head1 COPYRIGHT AND LICENSE
88  
89 This software is copyright (c) 2014 by John SJ Anderson.
90  
91 This is free software; you can redistribute it and/or modify it under
92 the same terms as the Perl 5 programming language system itself.
93  
94 =cut