[BACK]Return to json.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/json.pm, Revision 1.1

1.1     ! andrew      1: package Text::Todo::REST::API::Representations::json;
        !             2:
        !             3: # $AFresh1: text.pm,v 1.4 2010/01/26 06:03:11 andrew Exp $
        !             4:
        !             5: use base 'Text::Todo::REST::API::Representations';
        !             6:
        !             7: use warnings;
        !             8: use strict;
        !             9: use Carp;
        !            10:
        !            11: use version; our $VERSION = qv('0.0.1');
        !            12:
        !            13: use JSON;
        !            14:
        !            15: {
        !            16:     sub content_type { return 'text/plain' }
        !            17:
        !            18:     sub can_render {
        !            19:         my ( $class, $format ) = @_;
        !            20:         return if !defined $format;
        !            21:
        !            22:         my %handled_formats = map { $_ => 1 } qw(
        !            23:             text
        !            24:             txt
        !            25:         );
        !            26:
        !            27:         return exists $handled_formats{$format};
        !            28:     }
        !            29:
        !            30:     sub render_files {
        !            31:         my ( $self, $format, $data ) = @_;
        !            32:
        !            33:         $data ||= [];
        !            34:
        !            35:         return to_json($data);
        !            36:     }
        !            37:
        !            38:     sub render_list {
        !            39:         my ( $self, $format, $input ) = @_;
        !            40:
        !            41:         return if !defined $input;
        !            42:
        !            43:         my @input = $input;
        !            44:         if ( ref $input eq 'ARRAY' ) {
        !            45:             @input = @{$input};
        !            46:         }
        !            47:
        !            48:         return to_json(\@input);
        !            49:     }
        !            50:
        !            51:     sub render_entry {
        !            52:         my ( $self, $format, $input ) = @_;
        !            53:         return to_json($input);
        !            54:     }
        !            55: }
        !            56:
        !            57: 1;    # Magic true value required at end of module
        !            58: __END__
        !            59:
        !            60: =head1 NAME
        !            61:
        !            62: Text::Todo::REST::API::json - [One line description of module's purpose here]
        !            63:
        !            64:
        !            65: =head1 VERSION
        !            66:
        !            67: This document describes Text::Todo::REST::API::json version 0.0.1
        !            68:
        !            69:
        !            70: =head1 SYNOPSIS
        !            71:
        !            72:     use Text::Todo::REST::API::json;
        !            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::json 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>