HiD/VirtualPage.pm untested

filter: Statementstmt 0.0% 0 / 48 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 66 CC 2 SCAR 9.4
CC
2
Cov
0%
publish
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.6
1 # ABSTRACT: Pages injected during the build process that don't have corresponding files
2  
3  
4 package HiD::VirtualPage;
5 $HiD::VirtualPage::VERSION = '1.5';
6 use Moose;
7 use namespace::autoclean;
8  
9 use 5.014;
10 use utf8;
11 use autodie;
12 use warnings qw/ FATAL utf8 /;
13 use open qw/ :std :utf8 /;
14 use charnames qw/ :full /;
15 use feature qw/ unicode_strings /;
16  
17 use File::Basename qw/ fileparse /;
18 use File::Path qw/ make_path /;
19 use Path::Class qw/ file / ;
20  
21  
22 has output_filename => (
23 is => 'ro' ,
24 isa => 'Str' ,
25 required => 1 ,
26 );
27  
28 has content => (
29 is => 'ro' ,
30 isa => 'Str' ,
31 required => 1 ,
32 );
33  
34  
35 sub publish {
36 my $self = shift;
37  
38 my( undef , $dir ) = fileparse( $self->output_filename );
39  
40 make_path $dir unless -d $dir;
41  
42 open( my $out , '>:utf8' , $self->output_filename ) or die $!;
43 print $out $self->content;
44 close( $out );
45 }
46  
47 __PACKAGE__->meta->make_immutable;
48 1;
49  
50 __END__
51  
52 =pod
53  
54 =encoding utf-8
55  
56 =head1 NAME
57  
58 HiD::VirtualPage - Pages injected during the build process that don't have corresponding files
59  
60 =head1 SYNOPSIS
61  
62 my $page = HiD::VirtualPage->new({
63 output_filename => 'path/to/output/file' ,
64 content => 'content to go into file',
65 });
66  
67 =head1 DESCRIPTION
68  
69 Class representing a virtual "page" object -- that is, a page that will be
70 generated during the publishing process, but that doesn't have a direct
71 on-disk component or input prior to that. VirtualPages need to have their
72 content completely built and provided at the time they are
73 instantiated. Examples would be Atom and RSS feeds.
74  
75 =head1 ATTRIBUTES
76  
77 =head2 output_filename
78  
79 =head1 METHODS
80  
81 =head2 publish
82  
83 Publish -- write out to disk -- this data from this object.
84  
85 =head1 VERSION
86  
87 version 1.5
88  
89 =head1 AUTHOR
90  
91 John SJ Anderson <genehack@genehack.org>
92  
93 =head1 COPYRIGHT AND LICENSE
94  
95 This software is copyright (c) 2014 by John SJ Anderson.
96  
97 This is free software; you can redistribute it and/or modify it under
98 the same terms as the Perl 5 programming language system itself.
99  
100 =cut