| 1 | package Text::Template::Simple; | ||||||||||||||||||||||||||||
| 2 | 31 | $Text::Template::Simple::VERSION = '0.91'; | |||||||||||||||||||||||||||
| 3 | 31 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 31 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 31 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 31 | ▶ | use Text::Template::Simple::Cache; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 31 | ▶ | use Text::Template::Simple::Cache::ID; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 31 | ▶ | use Text::Template::Simple::Caller; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 31 | ▶ | use Text::Template::Simple::Compiler; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 31 | ▶ | use Text::Template::Simple::Compiler::Safe; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 31 | ▶ | use Text::Template::Simple::Constants qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 31 | ▶ | use Text::Template::Simple::Dummy; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 31 | ▶ | use Text::Template::Simple::IO; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 31 | ▶ | use Text::Template::Simple::Tokenizer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 31 | ▶ | use Text::Template::Simple::Util qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 31 | ▶ | use base qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | Text::Template::Simple::Base::Compiler | ||||||||||||||||||||||||||||
| 21 | Text::Template::Simple::Base::Examine | ||||||||||||||||||||||||||||
| 22 | Text::Template::Simple::Base::Include | ||||||||||||||||||||||||||||
| 23 | Text::Template::Simple::Base::Parser | ||||||||||||||||||||||||||||
| 24 | 31 | ); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 31 | my %CONNECTOR = qw( | |||||||||||||||||||||||||||
| 27 | Cache Text::Template::Simple::Cache | ||||||||||||||||||||||||||||
| 28 | Cache::ID Text::Template::Simple::Cache::ID | ||||||||||||||||||||||||||||
| 29 | IO Text::Template::Simple::IO | ||||||||||||||||||||||||||||
| 30 | Tokenizer Text::Template::Simple::Tokenizer | ||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 31 | my %DEFAULT = ( # default object attributes | |||||||||||||||||||||||||||
| 34 | delimiters => [ DELIMS ], # default delimiters | ||||||||||||||||||||||||||||
| 35 | cache => 0, # use cache or not | ||||||||||||||||||||||||||||
| 36 | cache_dir => EMPTY_STRING, # will use hdd intead of memory for caching... | ||||||||||||||||||||||||||||
| 37 | strict => 1, # set to false for toleration to un-declared vars | ||||||||||||||||||||||||||||
| 38 | safe => 0, # use safe compartment? | ||||||||||||||||||||||||||||
| 39 | header => 0, # template header. i.e. global codes. | ||||||||||||||||||||||||||||
| 40 | add_args => EMPTY_STRING, # will unshift template argument list. ARRAYref. | ||||||||||||||||||||||||||||
| 41 | warn_ids => 0, # warn template ids? | ||||||||||||||||||||||||||||
| 42 | capture_warnings => 0, # bool | ||||||||||||||||||||||||||||
| 43 | iolayer => EMPTY_STRING, # I/O layer for filehandles | ||||||||||||||||||||||||||||
| 44 | stack => EMPTY_STRING, # dump caller stack? | ||||||||||||||||||||||||||||
| 45 | user_thandler => undef, # user token handler callback | ||||||||||||||||||||||||||||
| 46 | monolith => 0, # use monolithic template & cache ? | ||||||||||||||||||||||||||||
| 47 | include_paths => [], # list of template dirs | ||||||||||||||||||||||||||||
| 48 | verbose_errors => 0, # bool | ||||||||||||||||||||||||||||
| 49 | pre_chomp => CHOMP_NONE, | ||||||||||||||||||||||||||||
| 50 | post_chomp => CHOMP_NONE, | ||||||||||||||||||||||||||||
| 51 | taint_mode => TAINT_CHECK_NORMAL, | ||||||||||||||||||||||||||||
| 52 | ); | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 31 | my @EXPORT_OK = qw( tts ); | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 29 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=6 SCAR=31.3
| |||||||||||||||||||||||||||||
| 57 | 29 | my($class, @args) = @_; | |||||||||||||||||||||||||||
| 58 | 29 | ▶ | return if ! @args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | my $caller = caller; | |||||||||||||||||||||||||||
| 60 | 0 | my %ok = map { ($_, $_) } @EXPORT_OK; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 31 | ▶ | no strict qw( refs ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 63 | 0 | foreach my $name ( @args ) { | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | fatal('tts.main.import.invalid', $name, $class) if ! $ok{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | fatal('tts.main.import.undef', $name, $class) if ! defined &{ $name }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | my $target = $caller . q{::} . $name; | |||||||||||||||||||||||||||
| 67 | 0 | ▶ | fatal('tts.main.import.redefine', $name, $caller) if defined &{ $target }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | *{ $target } = \&{ $name }; # install | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | return; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub tts { | ||||||||||||||||||||||||||
|
Subroutine
tts: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 75 | 0 | my @args = @_; | |||||||||||||||||||||||||||
| 76 | 0 | ▶ | fatal('tts.main.tts.args') if ! @args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my @new = ref $args[0] eq 'HASH' ? %{ shift @args } : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | return __PACKAGE__->new( @new )->compile( @args ); | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 45 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||
| 82 | 45 | my($class, @args) = @_; | |||||||||||||||||||||||||||
| 83 | 45 | ▶ | my %param = @args % 2 ? () : (@args); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 45 | my $self = [ map { undef } 0 .. MAXOBJFIELD ]; | |||||||||||||||||||||||||||
| 85 | 45 | bless $self, $class; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 45 | ▶ | LOG( CONSTRUCT => $self->class_id . q{ @ } . (scalar localtime time) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | if DEBUG(); | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 45 | my($fid, $fval); | |||||||||||||||||||||||||||
| 91 | 45 | INITIALIZE: foreach my $field ( keys %DEFAULT ) { | |||||||||||||||||||||||||||
| 92 | 810 | $fid = uc $field; | |||||||||||||||||||||||||||
| 93 | 810 | ▶ | next INITIALIZE if ! $class->can( $fid ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 810 | $fid = $class->$fid(); | |||||||||||||||||||||||||||
| 95 | 810 | $fval = delete $param{$field}; | |||||||||||||||||||||||||||
| 96 | 810 | ▶ | $self->[$fid] = defined $fval ? $fval : $DEFAULT{$field}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 45 | foreach my $bogus ( keys %param ) { | |||||||||||||||||||||||||||
| 100 | 0 | warn "'$bogus' is not a known parameter. Did you make a typo?\n"; | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 45 | $self->_init; | |||||||||||||||||||||||||||
| 104 | 45 | return $self; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 362 | ▶ | sub connector { | ||||||||||||||||||||||||||
|
Subroutine
connector: called CC=3 SCAR=13.3
Pod
documented
| |||||||||||||||||||||||||||||
| 108 | 362 | my $self = shift; | |||||||||||||||||||||||||||
| 109 | 362 | ▶ | my $id = shift || fatal('tts.main.connector.args'); | ||||||||||||||||||||||||||
|
Condition33%1/3
shift() || fatal('tts.main.connector.args')
MC/DC0%0/2
shift() || fatal('tts.main.connector.args')
shift()
fatal('tts.main.connector.args')
Truth table33%1/3
A || B
A= shift()B= fatal('tts.main.connector.args')
| |||||||||||||||||||||||||||||
| 110 | 362 | ▶ | return $CONNECTOR{ $id } || fatal('tts.main.connector.invalid', $id); | ||||||||||||||||||||||||||
|
Condition33%1/3
$CONNECTOR{$id} || fatal('tts.main.connector.invalid', $id)
MC/DC0%0/2
$CONNECTOR{$id} || fatal('tts.main.connector.invalid', $id)
$CONNECTOR{$id}
fatal('tts.main.connector.invalid', $id)
Truth table33%1/3
A || B
A= $CONNECTOR{$id}B= fatal('tts.main.connector.invalid', $id)
| |||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 649 | ▶ | sub cache { return shift->[CACHE_OBJECT] } | ||||||||||||||||||||||||||
|
Subroutine
cache: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 114 | 1222 | ▶ | sub io { return shift->[IO_OBJECT] } | ||||||||||||||||||||||||||
|
Subroutine
io: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 244 | ▶ | sub compile { | ||||||||||||||||||||||||||
|
Subroutine
compile: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 117 | 244 | my($self, @args) = @_; | |||||||||||||||||||||||||||
| 118 | 244 | my $rv = $self->_compile( @args ); | |||||||||||||||||||||||||||
| 119 | # we need to reset this to prevent false positives | ||||||||||||||||||||||||||||
| 120 | # the trick is: this is set in _compile() and sub includes call _compile() | ||||||||||||||||||||||||||||
| 121 | # instead of compile(), so it will only be reset here | ||||||||||||||||||||||||||||
| 122 | 241 | $self->[COUNTER_INCLUDE] = undef; | |||||||||||||||||||||||||||
| 123 | 241 | return $rv; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # -------------------[ P R I V A T E M E T H O D S ]------------------- # | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 45 | ▶ | sub _init { | ||||||||||||||||||||||||||
|
Subroutine
_init: called CC=15 SCAR=29.8
| |||||||||||||||||||||||||||||
| 129 | 45 | my $self = shift; | |||||||||||||||||||||||||||
| 130 | 45 | my $d = $self->[DELIMITERS]; | |||||||||||||||||||||||||||
| 131 | 45 | ▶ | my $bogus_args = $self->[ADD_ARGS] && ref $self->[ADD_ARGS] ne 'ARRAY'; | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->[15] && ref $self->[15] ne 'ARRAY'
MC/DC0%0/2
$self->[15] && ref $self->[15] ne 'ARRAY'
$self->[15]
ref $self->[15] ne 'ARRAY'
Truth table66%2/3
A && B
A= $self->[15]B= ref $self->[15] ne 'ARRAY'
| |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 45 | ▶ | fatal('tts.main.bogus_args') if $bogus_args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 45 | ▶ | fatal('tts.main.bogus_delims') if ref $d ne 'ARRAY' || $#{ $d } != 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $d ne "ARRAY" or $#{$d;} != 1
MC/DC0%0/2
ref $d ne "ARRAY" or $#{$d;} != 1
ref $d ne "ARRAY"
$#{$d;} != 1
Truth table33%1/3
A or B
A= ref $d ne "ARRAY"B= $#{$d;} != 1
| |||||||||||||||||||||||||||||
| 135 | 45 | ▶ | fatal('tts.main.dslen') if length($d->[DELIM_START]) < 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | 45 | ▶ | fatal('tts.main.delen') if length($d->[DELIM_END]) < 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 45 | ▶ | fatal('tts.main.dsws') if $d->[DELIM_START] =~ m{\s}xms; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 45 | ▶ | fatal('tts.main.dews') if $d->[DELIM_END] =~ m{\s}xms; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 45 | $self->[TYPE] = EMPTY_STRING; | |||||||||||||||||||||||||||
| 141 | 45 | $self->[COUNTER] = 0; | |||||||||||||||||||||||||||
| 142 | 45 | $self->[FAKER] = $self->_output_buffer_var; | |||||||||||||||||||||||||||
| 143 | 45 | $self->[FAKER_HASH] = $self->_output_buffer_var('hash'); | |||||||||||||||||||||||||||
| 144 | 45 | $self->[FAKER_SELF] = $self->_output_buffer_var('self'); | |||||||||||||||||||||||||||
| 145 | 45 | $self->[INSIDE_INCLUDE] = RESET_FIELD; | |||||||||||||||||||||||||||
| 146 | 45 | $self->[NEEDS_OBJECT] = 0; # the template needs $self ? | |||||||||||||||||||||||||||
| 147 | 45 | $self->[DEEP_RECURSION] = 0; # recursion detector | |||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 45 | ▶ | fatal('tts.main.init.thandler') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->[28] and ref $self->[28] ne "CODE"
MC/DC0%0/2
$self->[28] and ref $self->[28] ne "CODE"
$self->[28]
ref $self->[28] ne "CODE"
Truth table33%1/3
A and B
A= $self->[28]B= ref $self->[28] ne "CODE"
| |||||||||||||||||||||||||||||
| 150 | if $self->[USER_THANDLER] && ref $self->[USER_THANDLER] ne 'CODE'; | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 45 | ▶ | fatal('tts.main.init.include') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->[30] and ref $self->[30] ne "ARRAY"
MC/DC0%0/2
$self->[30] and ref $self->[30] ne "ARRAY"
$self->[30]
ref $self->[30] ne "ARRAY"
Truth table33%1/3
A and B
A= $self->[30]B= ref $self->[30] ne "ARRAY"
| |||||||||||||||||||||||||||||
| 153 | if $self->[INCLUDE_PATHS] && ref $self->[INCLUDE_PATHS] ne 'ARRAY'; | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | $self->[IO_OBJECT] = $self->connector('IO')->new( | ||||||||||||||||||||||||||||
| 156 | 45 | @{ $self }[ IOLAYER, INCLUDE_PATHS, TAINT_MODE ], | |||||||||||||||||||||||||||
| 157 | ); | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 45 | ▶ | if ( $self->[CACHE_DIR] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 2 | ▶ | $self->[CACHE_DIR] = $self->io->validate( dir => $self->[CACHE_DIR] ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | or fatal( 'tts.main.cdir' => $self->[CACHE_DIR] ); | ||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 45 | $self->[CACHE_OBJECT] = $self->connector('Cache')->new($self); | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 45 | return; | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 382 | ▶ | sub _output_buffer_var { | ||||||||||||||||||||||||||
|
Subroutine
_output_buffer_var: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 170 | 382 | my $self = shift; | |||||||||||||||||||||||||||
| 171 | 382 | ▶ | my $type = shift || 'scalar'; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 'scalar'
MC/DC100%1/1
shift() || 'scalar'
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 172 | 382 | ▶ | my $id = $type eq 'hash' ? {} | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 173 | : $type eq 'array' ? [] | ||||||||||||||||||||||||||||
| 174 | : \my $fake | ||||||||||||||||||||||||||||
| 175 | ; | ||||||||||||||||||||||||||||
| 176 | 382 | $id = "$id"; | |||||||||||||||||||||||||||
| 177 | 382 | $id .= int rand $$; # . rand() . time; | |||||||||||||||||||||||||||
| 178 | 382 | $id =~ tr/a-zA-Z_0-9//cd; | |||||||||||||||||||||||||||
| 179 | 382 | ▶ | $id =~ s{SCALAR}{SELF}xms if $type eq 'self'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 382 | return q{$} . $id; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 3 | ▶ | sub class_id { | ||||||||||||||||||||||||||
|
Subroutine
class_id: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 184 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 185 | 3 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||
| 186 | 3 | return sprintf q{%s v%s}, $class, $self->VERSION; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub _tidy { ## no critic (ProhibitUnusedPrivateSubroutines) | ||||||||||||||||||||||||||
|
Subroutine
_tidy: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 190 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 191 | 0 | my $code = shift; | |||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | TEST_TIDY: { | ||||||||||||||||||||||||||||
| 194 | 0 | local($@, $SIG{__DIE__}); | |||||||||||||||||||||||||||
| 195 | 0 | my $ok = eval { require Perl::Tidy; 1; }; | |||||||||||||||||||||||||||
| 196 | 0 | ▶ | if ( ! $ok ) { # :( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 0 | $code =~ s{;}{;\n}xmsgo; # new lines makes it easy to debug | |||||||||||||||||||||||||||
| 198 | 0 | return $code; | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | # We have Perl::Tidy, yay! | ||||||||||||||||||||||||||||
| 203 | 0 | my($buf, $stderr); | |||||||||||||||||||||||||||
| 204 | 0 | my @argv; # extra arguments | |||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 0 | Perl::Tidy::perltidy( | |||||||||||||||||||||||||||
| 207 | source => \$code, | ||||||||||||||||||||||||||||
| 208 | destination => \$buf, | ||||||||||||||||||||||||||||
| 209 | stderr => \$stderr, | ||||||||||||||||||||||||||||
| 210 | argv => \@argv, | ||||||||||||||||||||||||||||
| 211 | ); | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 0 | ▶ | LOG( TIDY_WARNING => $stderr ) if $stderr; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 0 | return $buf; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 218 | 0 | ▶ | my $self = shift || return; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 219 | 0 | undef $self->[CACHE_OBJECT]; | |||||||||||||||||||||||||||
| 220 | 0 | undef $self->[IO_OBJECT]; | |||||||||||||||||||||||||||
| 221 | 0 | @{ $self } = (); | |||||||||||||||||||||||||||
| 222 | 0 | ▶ | LOG( DESTROY => ref $self ) if DEBUG(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 0 | return; | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 31 | 1; | |||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | __END__ | ||||||||||||||||||||||||||||