File Coverage

blib/lib/Dancer2/Plugin/DebugDump.pm
Criterion Covered Total %
statement 12 17 70.5
branch n/a
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 17 23 73.9


line stmt bran cond sub pod time code
1             package Dancer2::Plugin::DebugDump;
2             $Dancer2::Plugin::DebugDump::VERSION = '0.41';
3 1     1   56468 use strict;
  1         3  
  1         22  
4 1     1   4 use warnings;
  1         1  
  1         20  
5              
6 1     1   473 use Dancer2::Plugin;
  1         181110  
  1         54  
7 1     1   34616 use Data::Dumper qw(Dumper);
  1         5550  
  1         202  
8              
9             plugin_keywords 'ddump';
10              
11             sub ddump {
12 0     0 1   my ($s, @data) = @_;
13 0           my $output = '';
14 0           foreach my $content (@data) {
15 0           $output .= Dumper $content;
16             }
17 0           $s->dsl->debug("DEBUG DUMP:\n" . $output . "\n");
18             }
19              
20             1; # Magic true value required at end of module
21              
22             =pod
23              
24             =head1 NAME
25              
26             Dancer2::Plugin::DebugDump - Modified debug behavior to create multi-line output that's easier for mere mortals to parse.
27              
28             =head1 VERSION
29              
30             version 0.41
31              
32             =head1 OVERVIEW
33              
34             L, is a simple plugin for the L web application framework. The target audience for this software is Dancer2 developers that use Dancer2's C keyword during software development. It's purpose is to make the C output in the log files or console easier to discern by formatting it across several lines.
35              
36             =head1 SYNOPSIS
37              
38             By default, Dancer2's C keyword outputs data structures to a single line. This plugin runs variables through C to produce output that is easier to read.
39              
40             use Dancer2;
41             use Dancer2::Plugin::DebugDump;
42              
43             my $data_stucture = [ { 'key1' => 'value', 'key2' => 'value' }, { 'key1' => 'value' , 'key2' => 'value' } ];
44             ddump($data_structure);
45              
46             # Sample output to your log or console
47             DEBUG DUMP:
48             $VAR1 = [
49             {
50             'key1' => 'value',
51             'key2' => 'value'
52             },
53             {
54             'key1' => 'value',
55             'key2' => 'value',
56             },
57             ];
58              
59             # Accepts multiple arguments, each argument should be a scalar or a reference
60             ddump($data_structure, $scalar_var, \@array_var, \%hash_var, ... );
61              
62             =head1 KEYWORDS
63              
64             =head2 ddump
65              
66             Accepts list of scalars and references which are processed through Dumper before getting sent to Dancer2's built-in C keyword. See Synopsis for usaage.
67              
68             =head1 CONFIGURATION
69              
70             DebugDump requires no configuration files or environment variables.
71              
72             =head1 DEPENDENCIES
73              
74             L;
75              
76             =head1 INCOMPATIBILITIES
77              
78             None reported.
79              
80             =for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
81              
82             =head1 SUPPORT
83              
84             =head2 Perldoc
85              
86             You can find documentation for this module with the perldoc command.
87              
88             perldoc Dancer2::Plugin::DebugDump
89              
90             =head2 Websites
91              
92             The following websites have more information about this module, and may be of help to you. As always,
93             in addition to those websites please use your favorite search engine to discover more resources.
94              
95             =over 4
96              
97             =item *
98              
99             MetaCPAN
100              
101             A modern, open-source CPAN search engine, useful to view POD in HTML format.
102              
103             L
104              
105             =back
106              
107             =head2 Source Code
108              
109             The code is open to the world, and available for you to hack on. Please feel free to browse it and play
110             with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull
111             from your repository :)
112              
113             L
114              
115             git clone git://github.com/sdondley/Dancer2-Plugin-DebugDump.git
116              
117             =head1 BUGS AND LIMITATIONS
118              
119             You can make new bug reports, and view existing ones, through the
120             web interface at L.
121              
122             =head1 MOTIVATION
123              
124             I'm new to Dancer2 development and wrote this plugin to scratch a minor itch and to learn how to write a basic Dancer2 module. It's also my first CPAN module.
125              
126             =head1 DEVELOPMENT NOTES
127              
128             This software is actively maintained. Further releases are expected to help exercise my budding software development skills. Feedback, suggestions, and contributions are greatly appreciated and welcome.
129              
130             I'm ignorant as to whether there is a better way to solve this problem than with a plugin. If there is a simpler, more elegant solution, I'm happy to hear it and will deprecate this module.
131              
132             =head1 SEE ALSO
133              
134             L man page.
135             L man page.
136             L man page.
137              
138             =head1 AUTHOR
139              
140             Steve Dondley
141              
142             =head1 COPYRIGHT AND LICENSE
143              
144             This software is copyright (c) 2017 by Steve Dondley.
145              
146             This is free software; you can redistribute it and/or modify it under
147             the same terms as the Perl 5 programming language system itself.
148              
149             =head1 DISCLAIMER OF WARRANTY
150              
151             BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
152             FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
153             OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
154             PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
155             EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
156             WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
157             ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
158             YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
159             NECESSARY SERVICING, REPAIR, OR CORRECTION.
160              
161             IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
162             WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
163             REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
164             LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
165             OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
166             THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
167             RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
168             FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
169             SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
170             SUCH DAMAGES.
171              
172             =cut
173              
174             __END__