| 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
| |||||||||||||
| 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 || {}
MC/DC100%1/1
$params || {}
$params
Truth table100%2/2
A
A= $params
| |||||||||||||
| 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
| |||||||||||||
| 60 | |||||||||||||
| 61 | 78 | ▶ | $dumper_obj->$arg( $val ) if defined $val; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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/&/&/g; | |||||||||||
| 76 | 1 | s/</</g; | |||||||||||
| 77 | 1 | s/>/>/g; | |||||||||||
| 78 | 1 | s/"/"/g; | |||||||||||
| 79 | 1 | s/'/'/g; | |||||||||||
| 80 | 1 | s/\n/<br>\n/g; | |||||||||||
| 81 | } | ||||||||||||
| 82 | |||||||||||||
| 83 | 1 | return $content; | |||||||||||
| 84 | } | ||||||||||||
| 85 | |||||||||||||
| 86 | 2 | 1; | |||||||||||
| 87 | |||||||||||||
| 88 | __END__ | ||||||||||||