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

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

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