File Coverage

lib/DataFlow/Proc/JSON.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package DataFlow::Proc::JSON;
2              
3 1     1   81661 use strict;
  1         2  
  1         38  
4 1     1   5 use warnings;
  1         2  
  1         170  
5              
6             # ABSTRACT: A JSON converting processor
7              
8             our $VERSION = '1.112100'; # VERSION
9              
10 1     1   551 use Moose;
  0            
  0            
11             extends 'DataFlow::Proc::Converter';
12              
13             use namespace::autoclean;
14             use JSON;
15              
16             sub _policy {
17             return shift->direction eq 'CONVERT_TO' ? 'ArrayRef' : 'Scalar';
18             }
19              
20             has '+converter' => (
21             lazy => 1,
22             default => sub {
23             my $self = shift;
24             return $self->has_converter_opts
25             ? JSON::Any->new( $self->converter_opts )
26             : JSON::Any->new;
27             },
28             handles => {
29             'json' => sub { shift->converter(@_) },
30             'json_opts' => sub { shift->converter_opts(@_) },
31             'has_json_opts' => sub { shift->has_converter_opts },
32             },
33             init_arg => 'json',
34             );
35              
36             has '+converter_opts' => ( 'init_arg' => 'json_opts', );
37              
38             sub _build_subs {
39             my $self = shift;
40             return {
41             'CONVERT_TO' => sub {
42             return $self->converter->to_json($_);
43             },
44             'FROM_JSON' => sub {
45             return $self->converter->from_json($_);
46             },
47             };
48             }
49              
50             __PACKAGE__->meta->make_immutable;
51              
52             1;
53              
54             __END__
55             =pod
56              
57             =encoding utf-8
58              
59             =head1 NAME
60              
61             DataFlow::Proc::JSON - A JSON converting processor
62              
63             =head1 VERSION
64              
65             version 1.112100
66              
67             =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders
68              
69             =head1 SUPPORT
70              
71             =head2 Perldoc
72              
73             You can find documentation for this module with the perldoc command.
74              
75             perldoc DataFlow::Proc::JSON
76              
77             =head2 Websites
78              
79             The following websites have more information about this module, and may be of help to you. As always,
80             in addition to those websites please use your favorite search engine to discover more resources.
81              
82             =over 4
83              
84             =item *
85              
86             Search CPAN
87              
88             The default CPAN search engine, useful to view POD in HTML format.
89              
90             L<http://search.cpan.org/dist/DataFlow-Proc-JSON>
91              
92             =item *
93              
94             AnnoCPAN
95              
96             The AnnoCPAN is a website that allows community annonations of Perl module documentation.
97              
98             L<http://annocpan.org/dist/DataFlow-Proc-JSON>
99              
100             =item *
101              
102             CPAN Ratings
103              
104             The CPAN Ratings is a website that allows community ratings and reviews of Perl modules.
105              
106             L<http://cpanratings.perl.org/d/DataFlow-Proc-JSON>
107              
108             =item *
109              
110             CPAN Forum
111              
112             The CPAN Forum is a web forum for discussing Perl modules.
113              
114             L<http://cpanforum.com/dist/DataFlow-Proc-JSON>
115              
116             =item *
117              
118             CPANTS
119              
120             The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.
121              
122             L<http://cpants.perl.org/dist/overview/DataFlow-Proc-JSON>
123              
124             =item *
125              
126             CPAN Testers
127              
128             The CPAN Testers is a network of smokers who run automated tests on uploaded CPAN distributions.
129              
130             L<http://www.cpantesters.org/distro/D/DataFlow-Proc-JSON>
131              
132             =item *
133              
134             CPAN Testers Matrix
135              
136             The CPAN Testers Matrix is a website that provides a visual way to determine what Perls/platforms PASSed for a distribution.
137              
138             L<http://matrix.cpantesters.org/?dist=DataFlow-Proc-JSON>
139              
140             =back
141              
142             =head2 Email
143              
144             You can email the author of this module at C<RUSSOZ at cpan.org> asking for help with any problems you have.
145              
146             =head2 Internet Relay Chat
147              
148             You can get live help by using IRC ( Internet Relay Chat ). If you don't know what IRC is,
149             please read this excellent guide: L<http://en.wikipedia.org/wiki/Internet_Relay_Chat>. Please
150             be courteous and patient when talking to us, as we might be busy or sleeping! You can join
151             those networks/channels and get help:
152              
153             =over 4
154              
155             =item *
156              
157             irc.perl.org
158              
159             You can connect to the server at 'irc.perl.org' and join this channel: #sao-paulo.pm then talk to this person for help: russoz.
160              
161             =back
162              
163             =head2 Bugs / Feature Requests
164              
165             Please report any bugs or feature requests by email to C<bug-dataflow-proc-json at rt.cpan.org>, or through
166             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DataFlow-Proc-JSON>. You will be automatically notified of any
167             progress on the request by the system.
168              
169             =head2 Source Code
170              
171             The code is open to the world, and available for you to hack on. Please feel free to browse it and play
172             with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
173             from your repository :)
174              
175             L<https://github.com/russoz/DataFlow-Proc-JSON>
176              
177             git clone https://github.com/russoz/DataFlow-Proc-JSON
178              
179             =head1 AUTHOR
180              
181             Alexei Znamensky <russoz@cpan.org>
182              
183             =head1 COPYRIGHT AND LICENSE
184              
185             This software is copyright (c) 2011 by Alexei Znamensky.
186              
187             This is free software; you can redistribute it and/or modify it under
188             the same terms as the Perl 5 programming language system itself.
189              
190             =head1 BUGS AND LIMITATIONS
191              
192             No bugs have been reported.
193              
194             Please report any bugs or feature requests through the web interface at
195             L<http://rt.cpan.org>.
196              
197             =head1 DISCLAIMER OF WARRANTY
198              
199             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
200             FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT
201             WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER
202             PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND,
203             EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
204             IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
205             PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
206             SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME
207             THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
208              
209             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
210             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
211             REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE
212             TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR
213             CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
214             SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
215             RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
216             FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
217             SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
218             DAMAGES.
219              
220             =cut
221