| 1 | package Toader::Render::Entry::backends::html; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use base 'Error::Helper'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | =head1 NAME | ||||||||||
| 8 | |||||||||||
| 9 | Toader::Render::Entry::backends::html - This handles the html backend stuff for Toader::Render::Entry. | ||||||||||
| 10 | |||||||||||
| 11 | =head1 VERSION | ||||||||||
| 12 | |||||||||||
| 13 | Version 0.1.0 | ||||||||||
| 14 | |||||||||||
| 15 | =cut | ||||||||||
| 16 | |||||||||||
| 17 | 1 | our $VERSION = '0.1.0'; | |||||||||
| 18 | |||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||
| 20 | |||||||||||
| 21 | use Toader::Render::Entry::backends::html; | ||||||||||
| 22 | |||||||||||
| 23 | my $renderer=Toader::Render::Directory::backends::html->new({ toader=>$toader, obj=>$entryObj }); | ||||||||||
| 24 | my $rendered; | ||||||||||
| 25 | if ( $renderer->error ){ | ||||||||||
| 26 | warn( 'Error:'.$renderer->error.': '.$renderer->errorString ); | ||||||||||
| 27 | }else{ | ||||||||||
| 28 | $rendered=$renderer->render($torender); | ||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | While this will error etc, this module is basically a pass through as HTML the native. | ||||||||||
| 32 | |||||||||||
| 33 | =head1 METHODS | ||||||||||
| 34 | |||||||||||
| 35 | =head2 new | ||||||||||
| 36 | |||||||||||
| 37 | This initiates the object. | ||||||||||
| 38 | |||||||||||
| 39 | =head3 args hash ref | ||||||||||
| 40 | |||||||||||
| 41 | =head4 obj | ||||||||||
| 42 | |||||||||||
| 43 | This is the L<Toader::Entry> object to render. | ||||||||||
| 44 | |||||||||||
| 45 | =head4 toader | ||||||||||
| 46 | |||||||||||
| 47 | This is the L<Toader> object to use. | ||||||||||
| 48 | |||||||||||
| 49 | my $foo=Toader::Render::Entry::backends::html->new(\%args); | ||||||||||
| 50 | if($foo->error){ | ||||||||||
| 51 | warn('error: '.$foo->error.":".$foo->errorString); | ||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | =cut | ||||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | sub new{ | ||||||||
|
Subroutine
new: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||
| 57 | 0 | my %args; | |||||||||
| 58 | 0 | ▶ | if(defined($_[1])){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 0 | %args= %{$_[1]}; | |||||||||
| 60 | }; | ||||||||||
| 61 | |||||||||||
| 62 | 0 | my $self={ | |||||||||
| 63 | error=>undef, | ||||||||||
| 64 | errorString=>'', | ||||||||||
| 65 | perror=>undef, | ||||||||||
| 66 | errorExtra=>{ | ||||||||||
| 67 | flags=>{ | ||||||||||
| 68 | 1=>'noObj', | ||||||||||
| 69 | 2=>'noToaderObj', | ||||||||||
| 70 | 3=>'objPerror', | ||||||||||
| 71 | 4=>'toaderPerror', | ||||||||||
| 72 | 5=>'noDirSet', | ||||||||||
| 73 | 6=>'nothingToRender', | ||||||||||
| 74 | }, | ||||||||||
| 75 | }, | ||||||||||
| 76 | }; | ||||||||||
| 77 | 0 | bless $self; | |||||||||
| 78 | |||||||||||
| 79 | #make sure we have a Toader::Entry object. | ||||||||||
| 80 | 0 | ▶ | if ( ! defined( $args{obj} ) ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | 0 | $self->{perror}=1; | |||||||||
| 82 | 0 | $self->{error}=1; | |||||||||
| 83 | 0 | $self->{errorString}='Nothing defined for the Toader::Directory object'; | |||||||||
| 84 | 0 | $self->warn; | |||||||||
| 85 | 0 | return $self; | |||||||||
| 86 | } | ||||||||||
| 87 | 0 | ▶ | if ( ref( $args{obj} ) ne 'Toader::Entry' ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 88 | 0 | $self->{perror}=1; | |||||||||
| 89 | 0 | $self->{error}=1; | |||||||||
| 90 | $self->{errorString}='The specified object is not a Toader::Entry object, but a "'. | ||||||||||
| 91 | 0 | ref( $args{obj} ).'"'; | |||||||||
| 92 | 0 | $self->warn; | |||||||||
| 93 | 0 | return $self; | |||||||||
| 94 | } | ||||||||||
| 95 | 0 | $self->{obj}=$args{obj}; | |||||||||
| 96 | |||||||||||
| 97 | #make sure the object does not have a permanent error set | ||||||||||
| 98 | 0 | ▶ | if( ! $self->{obj}->errorblank ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 99 | 0 | $self->{perror}=1; | |||||||||
| 100 | 0 | $self->{error}=3; | |||||||||
| 101 | 0 | $self->{errorString}='The Toader::Entry object has a permanent error set'; | |||||||||
| 102 | 0 | $self->warn; | |||||||||
| 103 | 0 | return $self; | |||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | #make sure a Toader object is given | ||||||||||
| 107 | 0 | ▶ | if ( ! defined( $args{toader} ) ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 108 | 0 | $self->{perror}=1; | |||||||||
| 109 | 0 | $self->{error}=2; | |||||||||
| 110 | 0 | $self->{errorString}='Nothing defined for the Toader object'; | |||||||||
| 111 | 0 | $self->warn; | |||||||||
| 112 | 0 | return $self; | |||||||||
| 113 | } | ||||||||||
| 114 | 0 | ▶ | if ( ref( $args{toader} ) ne 'Toader' ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 115 | 0 | $self->{perror}=1; | |||||||||
| 116 | 0 | $self->{error}=2; | |||||||||
| 117 | $self->{errorString}='The specified object is not a Toader object, but a "'. | ||||||||||
| 118 | 0 | ref( $args{toader} ).'"'; | |||||||||
| 119 | 0 | $self->warn; | |||||||||
| 120 | 0 | return $self; | |||||||||
| 121 | } | ||||||||||
| 122 | 0 | $self->{toader}=$args{toader}; | |||||||||
| 123 | |||||||||||
| 124 | #make sure the Toader object does not have a permanent error set | ||||||||||
| 125 | 0 | ▶ | if( ! $self->{toader}->errorblank ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 126 | 0 | $self->{perror}=1; | |||||||||
| 127 | 0 | $self->{error}=4; | |||||||||
| 128 | 0 | $self->{errorString}='The Toader object has an permanent error set'; | |||||||||
| 129 | 0 | $self->warn; | |||||||||
| 130 | 0 | return $self; | |||||||||
| 131 | } | ||||||||||
| 132 | |||||||||||
| 133 | #make sure a directory is set | ||||||||||
| 134 | 0 | ▶ | if( ! defined( $self->{obj}->dirGet ) ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 135 | 0 | $self->{perror}=1; | |||||||||
| 136 | 0 | $self->{error}=5; | |||||||||
| 137 | 0 | $self->{errorString}='The Toader::Entry object does not have a directory set'; | |||||||||
| 138 | 0 | $self->warn; | |||||||||
| 139 | 0 | return $self; | |||||||||
| 140 | } | ||||||||||
| 141 | |||||||||||
| 142 | 0 | return $self; | |||||||||
| 143 | } | ||||||||||
| 144 | |||||||||||
| 145 | =head2 render | ||||||||||
| 146 | |||||||||||
| 147 | This renders the object. | ||||||||||
| 148 | |||||||||||
| 149 | No arguments are taken. | ||||||||||
| 150 | |||||||||||
| 151 | =cut | ||||||||||
| 152 | |||||||||||
| 153 | 0 | ▶ | sub render{ | ||||||||
|
Subroutine
render: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 154 | 0 | my $self=$_[0]; | |||||||||
| 155 | 0 | my $torender=$_[1]; | |||||||||
| 156 | |||||||||||
| 157 | 0 | ▶ | if ( ! $self->errorblank ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 158 | 0 | return undef; | |||||||||
| 159 | } | ||||||||||
| 160 | |||||||||||
| 161 | 0 | ▶ | if ( !defined( $torender ) ){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 162 | 0 | $self->{error}=6; | |||||||||
| 163 | 0 | $self->{errorString}='Nothing to render specified'; | |||||||||
| 164 | 0 | $self->warn; | |||||||||
| 165 | 0 | return undef; | |||||||||
| 166 | } | ||||||||||
| 167 | |||||||||||
| 168 | |||||||||||
| 169 | |||||||||||
| 170 | 0 | return $torender; | |||||||||
| 171 | } | ||||||||||
| 172 | |||||||||||
| 173 | =head1 ERROR CODES | ||||||||||
| 174 | |||||||||||
| 175 | =head2 1, noObj | ||||||||||
| 176 | |||||||||||
| 177 | No L<Toader::Entry> object specified. | ||||||||||
| 178 | |||||||||||
| 179 | =head2 2, noToaderObj | ||||||||||
| 180 | |||||||||||
| 181 | No L<Toader> object specified. | ||||||||||
| 182 | |||||||||||
| 183 | =head2 3, objPerror | ||||||||||
| 184 | |||||||||||
| 185 | The L<Toader::Entry> object has a permanent error set. | ||||||||||
| 186 | |||||||||||
| 187 | =head2 4, toaderPerror | ||||||||||
| 188 | |||||||||||
| 189 | The L<Toader> object has a permanent error set. | ||||||||||
| 190 | |||||||||||
| 191 | =head2 5, noDirSet | ||||||||||
| 192 | |||||||||||
| 193 | The L<Toader::Entry> object does not have a directory set. | ||||||||||
| 194 | |||||||||||
| 195 | =head2 6, nothingToRender | ||||||||||
| 196 | |||||||||||
| 197 | Nothing specified to render. | ||||||||||
| 198 | |||||||||||
| 199 | =head1 AUTHOR | ||||||||||
| 200 | |||||||||||
| 201 | Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >> | ||||||||||
| 202 | |||||||||||
| 203 | =head1 BUGS | ||||||||||
| 204 | |||||||||||
| 205 | Please report any bugs or feature requests to C<bug-toader at rt.cpan.org>, or through | ||||||||||
| 206 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Toader>. I will be notified, and then you'll | ||||||||||
| 207 | automatically be notified of progress on your bug as I make changes. | ||||||||||
| 208 | |||||||||||
| 209 | =head1 SUPPORT | ||||||||||
| 210 | |||||||||||
| 211 | You can find documentation for this module with the perldoc command. | ||||||||||
| 212 | |||||||||||
| 213 | perldoc Toader::Render::Entry::backends::html | ||||||||||
| 214 | |||||||||||
| 215 | |||||||||||
| 216 | You can also look for information at: | ||||||||||
| 217 | |||||||||||
| 218 | =over 4 | ||||||||||
| 219 | |||||||||||
| 220 | =item * RT: CPAN's request tracker | ||||||||||
| 221 | |||||||||||
| 222 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Toader> | ||||||||||
| 223 | |||||||||||
| 224 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||
| 225 | |||||||||||
| 226 | L<http://annocpan.org/dist/Toader> | ||||||||||
| 227 | |||||||||||
| 228 | =item * CPAN Ratings | ||||||||||
| 229 | |||||||||||
| 230 | L<http://cpanratings.perl.org/d/Toader> | ||||||||||
| 231 | |||||||||||
| 232 | =item * Search CPAN | ||||||||||
| 233 | |||||||||||
| 234 | L<http://search.cpan.org/dist/Toader/> | ||||||||||
| 235 | |||||||||||
| 236 | =back | ||||||||||
| 237 | |||||||||||
| 238 | |||||||||||
| 239 | =head1 ACKNOWLEDGEMENTS | ||||||||||
| 240 | |||||||||||
| 241 | |||||||||||
| 242 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 243 | |||||||||||
| 244 | Copyright 2013. Zane C. Bowers-Hadley. | ||||||||||
| 245 | |||||||||||
| 246 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 247 | under the terms of either: the GNU General Public License as published | ||||||||||
| 248 | by the Free Software Foundation; or the Artistic License. | ||||||||||
| 249 | |||||||||||
| 250 | See http://dev.perl.org/licenses/ for more information. | ||||||||||
| 251 | |||||||||||
| 252 | |||||||||||
| 253 | =cut | ||||||||||
| 254 | |||||||||||
| 255 | 1 | 1; # End of Toader::Render::Entry::backends::html | |||||||||