lib/DBIx/DR/PerlishTemplate.pm

filter: Statementstmt 87.8% 254 / 289 Branchbran 82.1% 46 / 56 Conditioncond 46.6% 7 / 15 MC/DCmcdc 22.2% 2 / 9 Subroutinesub 100% 166 / 166 Podpod 0.0% 0 / 12 totaltotal 86.8% 475 / 547 SCAR 37.2
CC
37
Cov
85%
_parse_ep
10.0
_render
6.8
__ANON__
5.1
CRAP 41.4
« lib/DBIx/DR.pm ↑ Summary lib/DBIx/DR/PlPlaceHolders.pm »
1 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package DBIx::DR::PerlishTemplate;
6 5 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use DBIx::DR::ByteStream;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 has line_tag => (is => 'rw', isa => 'Str', default => '%');
12 3 has open_tag => (is => 'rw', isa => 'Str', default => '<%');
13 3 has close_tag => (is => 'rw', isa => 'Str', default => '%>');
14 3 has quote_mark => (is => 'rw', isa => 'Str', default => '=');
15 3 has immediate_mark => (is => 'rw', isa => 'Str', default => '==');
16  
17 3 has sql => (is => 'ro', isa => 'Str', default => '');
18 3 has variables => (is => 'ro', isa => 'ArrayRef');
19  
20 3 has template => (is => 'rw', isa => 'Str', default => '');
21 3 has template_file => (is => 'rw', isa => 'Str', default => '');
22  
23 3 has stashes => (is => 'ro', isa => 'ArrayRef');
24 3 has pretokens => (is => 'ro', isa => 'ArrayRef');
25 3 has prepretokens => (is => 'ro', isa => 'ArrayRef');
26 3 has parsed_template => (is => 'ro', isa => 'Str', default => '');
27 3 has namespace => (is => 'rw', isa => 'Str',
28 default => 'DBIx::DR::PerlishTemplate::Sandbox');
29  
30  
31 3 has sql_utf8 => (is => 'ro', isa => 'Bool', default => 1);
32 sub _render {
33 62 ▶ my ($_PTPL) = @_;
Subroutine _render: called CC=6 SCAR=19.1
34 62 my $_PTSUB;
35  
36 62 ▶ unless ($_PTPL->parsed_template) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_PTPL->parsed_template) { } 0 60 60
37 62 $_PTSUB = $_PTPL->{parsed_template} = $_PTPL->_parse;
38 } else {
39 2 $_PTSUB = $_PTPL->parsed_template;
40 }
41  
42 62 $_PTPL->{parsed_template} = $_PTSUB;
43  
44 5 ▶ my $esub = eval $_PTSUB;
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine __ANON__: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine BEGIN: called CC=1 SCAR=0.4
45 61 ▶ if (my $e = $@) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $@) 6 54 60
46 8 my $do_croak;
47 my $template;
48 8 ▶ if ($_PTPL->template_file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_PTPL->template_file) { } 3 3 6
49 5 $template = $_PTPL->template_file;
50 } else {
51 5 $do_croak = 1;
52 6 $template = 'inline template';
53 };
54 8 $e =~ s{ at .*?line (\d+)(\.\s*|,\s+.*?)?$}
55 7 [" at $template line " . ( $1 - $_PTPL->pre_lines )]gsme;
56  
57 8 ▶ if ($1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($1) 6 0 6
58 8 $e =~ s/\s*$/\n/g;
59 8 ▶ die $e unless $do_croak;
Branch: 1 branch
BranchTrueFalseTotal
unless $do_croak 3 3 6
60 6 croak $e;
61 }
62  
63 2 croak "$e at $template";
64 }
65  
66 56 $_PTPL->{sql} = '';
67 55 $_PTPL->{variables} = [];
68  
69 56 $esub->( @{ $_PTPL->stashes } );
70 55 1;
71 }
72  
73 sub render {
74 50 ▶ my ($self, $tpl, @args) = @_;
Subroutine render: called CC=1 SCAR=0.0
Pod undocumented
75 49 $self->{parsed_template} = '';
76 51 $self->template($tpl);
77 49 $self->template_file('');
78 50 $self->{stashes} = \@args;
79 66 $self->clean_namespace;
80 49 return $self->_render;
81 }
82  
83 sub render_file {
84 15 ▶ my ($self, $file, @args) = @_;
Subroutine render_file: called CC=4 SCAR=14.1
Pod undocumented
85 13 ▶ croak "File '@{[ $file // 'undef' ]}' not found or readable"
Branch: 1 branch
BranchTrueFalseTotal
unless -r $file 0 12 12
Condition0%0/2
$file // "undef"
l!l
00
MC/DC0%0/1
$file // "undef"
$file
Truth table0%0/2
A
A= $file
Aresult
11
00
86 unless -r $file;
87 14 open my $fh, '<:raw', $file;
88 13 my $data;
89  
90 14 { local $/; $data = <$fh> }
91  
92 15 ▶ utf8::decode $data if $self->sql_utf8;
Branch: 1 branch
BranchTrueFalseTotal
if $self->sql_utf8 12 0 12
93  
94 13 $self->{parsed_template} = '';
95 20 $self->template_file($file);
96 13 $self->template($data);
97 13 $self->{stashes} = \@args;
98 14 $self->clean_namespace;
99 13 return $self->_render;
100 }
101  
102 sub clean_prepends {
103 49 ▶ my ($self) = @_;
Subroutine clean_prepends: called CC=1 SCAR=0.0
Pod undocumented
104 50 $self->{pretokens} = [];
105 49 $self;
106 }
107  
108 sub clean_preprepends {
109 50 ▶ my ($self) = @_;
Subroutine clean_preprepends: called CC=1 SCAR=0.0
Pod undocumented
110 54 $self->{prepretokens} = [];
111 50 $self;
112 }
113  
114  
115 sub immediate {
116 269 ▶ my ($self, $str) = @_;
Subroutine immediate: called CC=4 SCAR=14.2
Pod undocumented
117 269 ▶ if (Scalar::Util::blessed $str) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($str)) { } 6 262 268
118 8 ▶ if ('DBIx::DR::ByteStream' eq Scalar::Util::blessed $str) {
Branch: 2 branches
BranchTrueFalseTotal
if ('DBIx::DR::ByteStream' eq builtin::blessed($str)) { } 6 0 6
elsif ($str->can('content')) { } 0 0 0
119 7 $self->{sql} .= $str->content;
120 } elsif ($str->can('content')) {
121 2 $self->{sql} .= $str->content;
122 } else {
123 1 croak "Can't extract content from " . Scalar::Util::blessed $str;
124 }
125 } else {
126 267 $self->{sql} .= $str;
127 }
128 269 return DBIx::DR::ByteStream->new('');
129 }
130  
131 sub add_bind_value {
132 65 ▶ my ($self, @values) = @_;
Subroutine add_bind_value: called CC=1 SCAR=0.0
Pod undocumented
133 65 push @{ $self->variables } => @values;
134 }
135  
136  
137 sub quote {
138 48 ▶ my ($self, $variable) = @_;
Subroutine quote: called CC=3 SCAR=11.0
Pod undocumented
139  
140 48 ▶ if (Scalar::Util::blessed $variable) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($variable)) 5 42 47
141 7 ▶ return $self->immediate($variable)
Branch: 1 branch
BranchTrueFalseTotal
if "DBIx::DR::ByteStream" eq builtin::blessed($variable) 5 0 5
142 if 'DBIx::DR::ByteStream' eq Scalar::Util::blessed $variable;
143 }
144  
145 46 $self->{sql} .= '?';
146 45 $self->add_bind_value($variable);
147 43 return DBIx::DR::ByteStream->new('');
148 }
149  
150 sub _parse {
151 63 ▶ my ($self) = @_;
Subroutine _parse: called CC=1 SCAR=0.0
152  
153 63 my $result = '';
154  
155 61 my $immediate_mark = $self->immediate_mark;
156 61 my $quote_mark = $self->quote_mark;
157  
158 my $code_cb = sub {
159 75 ▶ my ($t) = @_;
Subroutine __ANON__: called CC=5 SCAR=16.3
160 74 ▶ return unless defined $t and length $t;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $t and length $t 0 72 72
Condition33%1/3
defined $t and length $t
!ll&&!rl&&r
0072
MC/DC0%0/2
defined $t and length $t
defined $t length $t
Truth table33%1/3
A and B
A= defined $tB= length $t
ABresult
0X0
100
111
161  
162 73 ▶ if ($t =~ /^\Q$immediate_mark\E/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t =~ /^\Q$immediate_mark\E/) 12 60 72
163 13 $result .= join '',
164 'immediate(',
165 substr($t, length($immediate_mark)),
166 ');';
167 13 return;
168 }
169  
170 63 ▶ if ($t =~ /^\Q$quote_mark\E/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t =~ /^\Q$quote_mark\E/) 36 24 60
171 37 $result .= join '',
172 'quote(',
173 substr($t, length($quote_mark)),
174 ');';
175 37 return;
176 }
177  
178 44 $result .= "$t;"; # always place ';' at end of code.
179 61 };
180  
181 my $text_cb = sub {
182 314 ▶ my ($content) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.0
183 314 ▶ return unless defined $content and length $content;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $content and length $content 66 247 313
Condition66%2/3
defined $content and length $content
!ll&&!rl&&r
066247
MC/DC50%1/2
defined $content and length $content
defined $content length $content
Truth table66%2/3
A and B
A= defined $contentB= length $content
ABresult
0X0
100
111
184 249 $content =~ s/'/\\'/g;
185 248 $result .= "immediate('" . $content . "');";
186 62 };
187  
188 61 $self->_parse_ep($self->template, $text_cb, $code_cb);
189  
190 62 $result = join '',
191 'package ', $self->namespace, ';',
192 'BEGIN { ',
193 '*quote = sub { $_PTPL->quote(@_) };',
194 '*immediate = sub { $_PTPL->immediate(@_) };',
195 '};',
196 $self->preprepend,
197 'sub {', $self->prepend, $result, "\n}";
198  
199 61 return $result;
200 }
201  
202 sub _parse_ep {
203  
204 61 ▶ my ($self, $tpl, $text_cb, $code_cb) = @_;
Subroutine _parse_ep: called CC=10 SCAR=23.0
205  
206 #---------------------------------------------------------
207 # единственные три переменные из self
208 61 my $line_tag = $self->line_tag;
209 61 my $open_tag = $self->open_tag;
210 61 my $close_tag = $self->close_tag;
211 # по идее это можно было оформить в виде независимого кода
212 #---------------------------------------------------------
213  
214 62 my @lines = split /\n/, $tpl;
215  
216 61 my $st = 'text';
217 62 my $code_text;
218  
219 61 ▶ for (my $i = 0; $i < @lines; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @lines) 181 60 241
220 183 local $_ = $lines[$i];
221  
222 CODE:
223 226 ▶ if ($st eq 'code') {
Branch: 1 branch
BranchTrueFalseTotal
if ($st eq "code") 46 177 223
224 48 ▶ if (/^(.*?)\Q$close_tag\E(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^(.*?)\Q$close_tag\E(.*)/) { } 42 4 46
225 44 $_ = $2;
226 43 $code_cb->($code_text . $1);
227 48 $code_text = undef;
228 43 $st = 'text';
229 55 goto ANYTEXT;
230 } else {
231 5 $code_text .= $_;
232 8 $code_text .= "\n";
233 5 next;
234 }
235 }
236  
237 TEXT_BEGIN:
238 178 ▶ if (/^(\s*)\Q$line_tag\E(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^(\s*)\Q$line_tag\E(.*)/) 30 147 177
239 31 $text_cb->($1);
240 31 ▶ if ($i < $#lines) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#lines) { } 23 7 30
241 25 $code_cb->("$2\n");
242 } else {
243 8 $code_cb->($2);
244 }
245 30 next;
246 }
247  
248 ANYTEXT:
249 190 ▶ if (/^(.*?)\Q$open_tag\E(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^(.*?)\Q$open_tag\E(.*)/) { } 42 147 189
250 42 $_ = $2;
251 42 $text_cb->($1);
252 42 $code_text = '';
253 42 $st = 'code';
254 42 goto CODE;
255 } else {
256 147 $text_cb->($_);
257 147 ▶ $text_cb->("\n") if $i < $#lines;
Branch: 1 branch
BranchTrueFalseTotal
if $i < $#lines 94 53 147
258 147 next;
259 }
260 }
261 60 ▶ $text_cb->("<%" . $code_text) if defined $code_text and length $code_text;
Branch: 1 branch
BranchTrueFalseTotal
if defined $code_text and length $code_text 0 60 60
Condition33%1/3
defined $code_text and length $code_text
!ll&&!rl&&r
6000
MC/DC0%0/2
defined $code_text and length $code_text
defined $code_text length $code_text
Truth table33%1/3
A and B
A= defined $code_textB= length $code_text
ABresult
0X0
100
111
262 }
263  
264  
265 sub preprepend {
266 294 ▶ my ($self, @tokens) = @_;
Subroutine preprepend: called CC=4 SCAR=13.9
Pod undocumented
267 295 ▶ $self->{prepretokens} ||= [];
Condition100%2/2
$self->{"prepretokens"} ||= []
l!l
2931
MC/DC100%1/1
$self->{"prepretokens"} ||= []
$self->{"prepretokens"}
Truth table100%2/2
A
A= $self->{"prepretokens"}
Aresult
11
00
268 294 ▶ push @{ $self->prepretokens } => map "$_;\n", @tokens if @tokens;
Branch: 1 branch
BranchTrueFalseTotal
if @tokens 228 66 294
269 294 ▶ return join '' => @{ $self->prepretokens } if defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray 66 228 294
270 }
271  
272 sub prepend {
273 98 ▶ my ($self, @tokens) = @_;
Subroutine prepend: called CC=4 SCAR=13.9
Pod undocumented
274 109 ▶ $self->{pretokens} ||= [];
Condition50%1/2
$self->{"pretokens"} ||= []
l!l
980
MC/DC0%0/1
$self->{"pretokens"} ||= []
$self->{"pretokens"}
Truth table50%1/2
A
A= $self->{"pretokens"}
Aresult
11
00
275 98 ▶ push @{ $self->pretokens } => map "$_;", @tokens if @tokens;
Branch: 1 branch
BranchTrueFalseTotal
if @tokens 32 66 98
276 99 ▶ return join '' => @{ $self->pretokens } if defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray 66 32 98
277 }
278  
279  
280 sub pre_lines {
281 6 ▶ my ($self) = @_;
Subroutine pre_lines: called CC=2 SCAR=6.9
Pod undocumented
282 8 my $lines = 0;
283 6 $lines += @{[ /\n/g ]} for ($self->preprepend, $self->prepend);
284 7 return $lines;
285 }
286  
287 sub clean_prepend {
288 12 ▶ my ($self) = shift;
Subroutine clean_prepend: called CC=1 SCAR=0.0
Pod undocumented
289 12 $self->{pretokens} = [];
290 }
291  
292 sub clean_namespace {
293 60 ▶ my ($self) = @_;
Subroutine clean_namespace: called CC=2 SCAR=6.9
Pod undocumented
294 61 my $sb = $self->namespace;
295  
296 5 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
297 60 undef *{$sb . '::' . $_} for keys %{ $sb . '::' };
298 }
299  
300 3 1;
301  
302 =head1 NAME
303  
304 DBIx::DR::PerlishTemplate - template engine for L<DBIx::DR>.
305  
306 =head1 COPYRIGHT
307  
308 Copyright (C) 2011 Dmitry E. Oboukhov <unera@debian.org>
309 Copyright (C) 2011 Roman V. Nikolaev <rshadow@rambler.ru>
310  
311 This program is free software, you can redistribute it and/or
312 modify it under the terms of the Artistic License.
313  
314 =cut
315  
316  
317  
318  
319  
« lib/DBIx/DR.pm ↑ Summary lib/DBIx/DR/PlPlaceHolders.pm »