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