[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.5

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

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