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