lib/Template/Plugin/Dumper.pm

filter: Statementstmt 100% 37 / 37 Branchbran 83.3% 5 / 6 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 8 / 8 Podpod 75.0% 3 / 4 totaltotal 96.5% 56 / 58 CC 6 SCAR 8.0
CC
6
Cov
98%
get_dump_obj
4.0
new
2.0
dump_html
2.0
CRAP 2.2
« lib/Template/Exception.pm ↑ Summary blib/lib/Template/Plugin/Wrap.pm »
1 #==============================================================================
2 #
3 # Template::Plugin::Dumper
4 #
5 # DESCRIPTION
6 #
7 # A Template Plugin to provide a Template Interface to Data::Dumper
8 #
9 # AUTHOR
10 # Simon Matthews <sam@tt2.org>
11 #
12 # COPYRIGHT
13 # Copyright (C) 2000 Simon Matthews. All Rights Reserved
14 #
15 # This module is free software; you can redistribute it and/or
16 # modify it under the same terms as Perl itself.
17 #
18 #==============================================================================
19  
20 package Template::Plugin::Dumper;
21  
22 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 ▶use base 'Template::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
25 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 2 our $VERSION = '3.106';
28 2 ▶our $DEBUG = 0 unless defined $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Template::Plugin::Dumper::DEBUG 2 0 2
29 2 our @DUMPER_ARGS = qw( Indent Pad Varname Purity Useqq Terse Freezer
30 Toaster Deepcopy Quotekeys Bless Maxdepth Sortkeys );
31 2 our $AUTOLOAD;
32  
33 #==============================================================================
34 # ----- CLASS METHODS -----
35 #==============================================================================
36  
37 #------------------------------------------------------------------------
38 # new($context, \@params)
39 #------------------------------------------------------------------------
40  
41 8 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
42 8 my ($class, $context, $params) = @_;
43  
44 8 ▶ bless {
Condition100%2/2
$params || {}
l!l
26
MC/DC100%1/1
$params || {}
$params
Truth table100%2/2
A
A= $params
Aresult
11
00
45 _CONTEXT => $context,
46 params => $params || {},
47 }, $class;
48 }
49  
50 6 ▶sub get_dump_obj {
Subroutine get_dump_obj: called CC=4 SCAR=13.9
Pod undocumented
51 6 my $self = shift;
52  
53 6 my $dumper_obj = Data::Dumper->new( \@_ );
54  
55 6 my $params = $self->{ params };
56  
57 6 foreach my $arg ( @DUMPER_ARGS ) {
58 my $val = exists $params->{ lc $arg } ? $params->{ lc $arg }
59 78 ▶ : $params->{ $arg };
Branch: 1 branch
BranchTrueFalseTotal
exists $$params{lc $arg} ? : 3 75 78
60  
61 78 ▶ $dumper_obj->$arg( $val ) if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 5 73 78
62 }
63  
64 6 return $dumper_obj;
65 }
66  
67 6 ▶sub dump { scalar shift->get_dump_obj( @_ )->Dump() }
Subroutine dump: called CC=1 SCAR=0.0
Pod documented
68  
69 1 ▶sub dump_html {
Subroutine dump_html: called CC=2 SCAR=6.9
Pod documented
70 1 my $self = shift;
71  
72 1 my $content = $self->dump( @_ );
73  
74 1 for ($content) {
75 1 s/&/&amp;/g;
76 1 s/</&lt;/g;
77 1 s/>/&gt;/g;
78 1 s/"/&quot;/g;
79 1 s/'/&#39;/g;
80 1 s/\n/<br>\n/g;
81 }
82  
83 1 return $content;
84 }
85  
86 2 1;
87  
88 __END__
« lib/Template/Exception.pm ↑ Summary blib/lib/Template/Plugin/Wrap.pm »