[BACK]Return to text.pm CVS log [TXT][DIR] Up to [local] / todotxt / Text-Todo-REST-API / lib / Text / Todo / REST / API / Representations

Annotation of todotxt/Text-Todo-REST-API/lib/Text/Todo/REST/API/Representations/text.pm, Revision 1.4

1.1       andrew      1: package Text::Todo::REST::API::Representations::text;
                      2:
1.4     ! andrew      3: # $AFresh1: text.pm,v 1.3 2010/01/23 07:04:43 andrew Exp $
1.1       andrew      4:
1.2       andrew      5: use base 'Text::Todo::REST::API::Representations';
1.1       andrew      6:
                      7: use warnings;
                      8: use strict;
                      9: use Carp;
                     10:
                     11: use version; our $VERSION = qv('0.0.1');
                     12:
                     13: {
1.2       andrew     14:     sub content_type { return 'text/plain' }
1.1       andrew     15:
1.3       andrew     16:     sub can_render {
1.2       andrew     17:         my ( $class, $format ) = @_;
                     18:         return if !defined $format;
                     19:
                     20:         my %handled_formats = map { $_ => 1 } qw(
                     21:             text
                     22:             txt
                     23:         );
1.1       andrew     24:
                     25:         return exists $handled_formats{$format};
                     26:     }
                     27:
1.3       andrew     28:     sub render_files {
                     29:         my ( $self, $format, $data ) = @_;
                     30:
                     31:         $data ||= [];
1.1       andrew     32:
1.2       andrew     33:         my $output;
1.4     ! andrew     34:         foreach my $line ( @{$data} ) {
1.2       andrew     35:             $output .= "$line\n";
                     36:         }
                     37:         return $output;
                     38:     }
                     39:
1.3       andrew     40:     sub render_list {
                     41:         my ( $self, $format, $input ) = @_;
                     42:
1.4     ! andrew     43:         return if !defined $input;
1.3       andrew     44:
                     45:         my @input = $input;
1.4     ! andrew     46:         if ( ref $input eq 'ARRAY' ) {
        !            47:             @input = @{$input};
1.3       andrew     48:         }
1.1       andrew     49:
                     50:         my $output;
1.2       andrew     51:         foreach my $o (@input) {
                     52:             $output .= "$o->{text}\n";
1.1       andrew     53:         }
                     54:         return $output;
                     55:     }
1.2       andrew     56:
1.3       andrew     57:     sub render_entry {
1.2       andrew     58:         my ( $self, @args ) = @_;
1.3       andrew     59:         return $self->render_list(@args);
1.2       andrew     60:     }
1.1       andrew     61: }
                     62:
1.2       andrew     63: 1;    # Magic true value required at end of module
1.1       andrew     64: __END__
                     65:
                     66: =head1 NAME
                     67:
                     68: Text::Todo::REST::API::text - [One line description of module's purpose here]
                     69:
                     70:
                     71: =head1 VERSION
                     72:
                     73: This document describes Text::Todo::REST::API::text version 0.0.1
                     74:
                     75:
                     76: =head1 SYNOPSIS
                     77:
                     78:     use Text::Todo::REST::API::text;
                     79:
                     80: =for author to fill in:
                     81:     Brief code example(s) here showing commonest usage(s).
                     82:     This section will be as far as many users bother reading
                     83:     so make it as educational and exeplary as possible.
                     84:
                     85:
                     86: =head1 DESCRIPTION
                     87:
                     88: =for author to fill in:
                     89:     Write a full description of the module and its features here.
                     90:     Use subsections (=head2, =head3) as appropriate.
                     91:
                     92:
                     93: =head1 INTERFACE
                     94:
                     95: =for author to fill in:
                     96:     Write a separate section listing the public components of the modules
                     97:     interface. These normally consist of either subroutines that may be
                     98:     exported, or methods that may be called on objects belonging to the
                     99:     classes provided by the module.
                    100:
                    101:
                    102: =head1 DIAGNOSTICS
                    103:
                    104: =for author to fill in:
                    105:     List every single error and warning message that the module can
                    106:     generate (even the ones that will "never happen"), with a full
                    107:     explanation of each problem, one or more likely causes, and any
                    108:     suggested remedies.
                    109:
                    110: =over
                    111:
                    112: =item C<< Error message here, perhaps with %s placeholders >>
                    113:
                    114: [Description of error here]
                    115:
                    116: =item C<< Another error message here >>
                    117:
                    118: [Description of error here]
                    119:
                    120: [Et cetera, et cetera]
                    121:
                    122: =back
                    123:
                    124:
                    125: =head1 CONFIGURATION AND ENVIRONMENT
                    126:
                    127: =for author to fill in:
                    128:     A full explanation of any configuration system(s) used by the
                    129:     module, including the names and locations of any configuration
                    130:     files, and the meaning of any environment variables or properties
                    131:     that can be set. These descriptions must also include details of any
                    132:     configuration language used.
                    133:
                    134: Text::Todo::REST::API::text requires no configuration files or environment variables.
                    135:
                    136:
                    137: =head1 DEPENDENCIES
                    138:
                    139: =for author to fill in:
                    140:     A list of all the other modules that this module relies upon,
                    141:     including any restrictions on versions, and an indication whether
                    142:     the module is part of the standard Perl distribution, part of the
                    143:     module's distribution, or must be installed separately. ]
                    144:
                    145: None.
                    146:
                    147:
                    148: =head1 INCOMPATIBILITIES
                    149:
                    150: =for author to fill in:
                    151:     A list of any modules that this module cannot be used in conjunction
                    152:     with. This may be due to name conflicts in the interface, or
                    153:     competition for system or program resources, or due to internal
                    154:     limitations of Perl (for example, many modules that use source code
                    155:     filters are mutually incompatible).
                    156:
                    157: None reported.
                    158:
                    159:
                    160: =head1 BUGS AND LIMITATIONS
                    161:
                    162: =for author to fill in:
                    163:     A list of known problems with the module, together with some
                    164:     indication Whether they are likely to be fixed in an upcoming
                    165:     release. Also a list of restrictions on the features the module
                    166:     does provide: data types that cannot be handled, performance issues
                    167:     and the circumstances in which they may arise, practical
                    168:     limitations on the size of data sets, special cases that are not
                    169:     (yet) handled, etc.
                    170:
                    171: No bugs have been reported.
                    172:
                    173: Please report any bugs or feature requests to
                    174: C<bug-text-todo-rest-api-text@rt.cpan.org>, or through the web interface at
                    175: L<http://rt.cpan.org>.
                    176:
                    177:
                    178: =head1 AUTHOR
                    179:
                    180: Andrew Fresh  C<< <andrew@cpan.org> >>
                    181:
                    182:
                    183: =head1 LICENSE AND COPYRIGHT
                    184:
                    185: Copyright (c) 2010, Andrew Fresh C<< <andrew@cpan.org> >>. All rights reserved.
                    186:
                    187: This module is free software; you can redistribute it and/or
                    188: modify it under the same terms as Perl itself. See L<perlartistic>.
                    189:
                    190:
                    191: =head1 DISCLAIMER OF WARRANTY
                    192:
                    193: BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
                    194: FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
                    195: OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
                    196: PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
                    197: EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                    198: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
                    199: ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
                    200: YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
                    201: NECESSARY SERVICING, REPAIR, OR CORRECTION.
                    202:
                    203: IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
                    204: WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
                    205: REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
                    206: LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
                    207: OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
                    208: THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
                    209: RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
                    210: FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
                    211: SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
                    212: SUCH DAMAGES.

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>