blib/lib/Template/Plugin/ASCIITable.pm

filter: Statementstmt 83.2% 134 / 161 Branchbran 62.8% 44 / 70 Conditioncond 47.8% 11 / 23 MC/DCmcdc 20.0% 3 / 15 Subroutinesub 84.6% 22 / 26 Podpod 92.8% 13 / 14 totaltotal 73.4% 227 / 309 CC 48 SCAR 17.7
CC
48
Cov
74%
AUTOLOAD
12.0
_globals
10.8
draw
10.0
CRAP 5.9
↑ Summary
1 package Template::Plugin::ASCIITable;
2 1 ▶use base 'Template::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Text::ASCIITable;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use vars qw($VERSION $AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 $VERSION='0.2';
7  
8 =head1 NAME
9  
10 Template::Plugin::ASCIITable
11  
12 =head1 SYNOPSIS
13  
14 [% USE ASCIITable %]
15 blah
16 [% ASCIITable.cols('a', 'b', 'c');
17 ASCIITable.rows([1,2,3],['one','two','three']);
18 ASCIITable.draw() %]
19  
20 =head1 DESCRIPTION
21  
22 This module allows you to use L<Text::ASCIITable> in your templates.
23  
24 A plugin object will be instantiated with the directive:
25  
26 [% USE ASCIITable %]
27  
28 You can pass a number of parameters to the constructor, for example:
29  
30 [% USE ASCIITable(cols => ['a','b','c'], show=>'rowline') %]
31  
32 See L</Parameters> for details.
33  
34 To obtain the table, you invoke the C<draw> method, to which you can
35 pass the same parameters:
36  
37 [% ASCIITable.draw(rows=>[[1,2,3],['one','two','three']]) %]
38  
39 =head1 METHODS
40  
41 =head2 C<new>
42  
43 This is the plugin construtor. You should never call it directly: use
44 the C<USE> directive.
45  
46 =cut
47  
48 11 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
49 11 my ($class,$context,$params)=@_;
50 11 my $self=bless {hide=>{rowline=>1}},$class;
51 11 ▶ $self->handleParms(%$params) if $params;
Branch: 1 branch
BranchTrueFalseTotal
if $params 8 3 11
52 11 return $self;
53 }
54  
55 =head2 C<draw>
56  
57 This method invokes L<Text::ASCIITable> to obtain the textual
58 representation of the table, and returns it.
59  
60 You can pass various parameters to it, see L</Parameters>.
61  
62 =cut
63  
64 10 ▶sub draw {
Subroutine draw: called CC=10 SCAR=23.1
Pod documented
65 10 my ($self,@rest)=@_;
66 10 ▶ $self->handleParms(@rest) if @rest;
Branch: 1 branch
BranchTrueFalseTotal
if @rest 0 10 10
67 10 my $t=Text::ASCIITable->new({$self->_globals()});
68 10 $t->setCols($self->_colnames());
69 10 for my $c ($self->_colprops()) {
70 30 ▶ $t->alignCol($c->{name},$c->{align}) if $c->{align};
Branch: 1 branch
BranchTrueFalseTotal
if $c->{"align"} 2 28 30
71 30 ▶ $t->alignColName($c->{name},$c->{nalign}) if $c->{nalign};
Branch: 1 branch
BranchTrueFalseTotal
if $c->{"nalign"} 0 30 30
72 30 ▶ $t->setColWidth($c->{name},$c->{width},$c->{widen}) if ($c->{width}||-1)>0;
Branch: 1 branch
BranchTrueFalseTotal
if ($c->{"width"} || -1) > 0 2 28 30
Condition100%2/2
$c->{'width'} || -1
l!l
228
MC/DC100%1/1
$c->{'width'} || -1
$c->{'width'}
Truth table100%2/2
A
A= $c->{'width'}
Aresult
11
00
73 }
74 10 for my $r ($self->_rows()) {
75 20 $t->addRow($r)
76 }
77 10 my $ret=$t->draw($self->_style());
78 10 my ($l,$r)=$self->_squeeze();
79 10 ▶ $ret=~s/^.{$l}//mg if $l;
Branch: 1 branch
BranchTrueFalseTotal
if $l 1 9 10
80 10 ▶ $ret=~s/.{$r}$//mg if $r;
Branch: 1 branch
BranchTrueFalseTotal
if $r 1 9 10
81  
82 10 $ret=~s/\n$//;
83 10 return $ret;
84 }
85  
86 1 my %paramSubs=(
87 hide => \&hide,
88 show => \&show,
89 cols => \&cols,
90 errors => \&errors,
91 reporterrors => \&errors,
92 allow => \&allow,
93 deny => \&deny,
94 alignheadrow => \&alignHeadRow,
95 rows => \&rows,
96 style => \&style,
97 );
98  
99 =head1 Parameters
100  
101 These parameters can be set in three ways:
102  
103 =over 4
104  
105 =item *
106  
107 passing them to the constructor
108  
109 =item *
110  
111 passing them to the C<draw> call
112  
113 =item *
114  
115 setting them with individual method calls
116  
117 =back
118  
119 All three forms are case-insensitive: you can do
120  
121 [% USE t=ASCIITable(allow=>'HTML') %]
122 [% t.Allow('html') %]
123 [% t.draw(ALLOW=>'HtMl') %]
124  
125 =cut
126  
127 12 ▶sub handleParms {
Subroutine handleParms: called CC=3 SCAR=11.4
Pod undocumented
128 12 my ($self,%params)=@_;
129 12 for my $k (keys %params) {
130 13 ▶ if (exists $paramSubs{lc($k)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $paramSubs{lc $k}) { } 13 0 13
131 13 $paramSubs{lc($k)}->($self,$params{$k});
132 } else {
133 0 _die("no such parameter $k");
134 }
135 }
136 12 return;
137 }
138  
139 =head2 C<hide>
140  
141 This parameter accepts a list of names of features to hide. The
142 recognized names are:
143  
144 =over 4
145  
146 =item C<firstline>
147  
148 The very first decoration line of the table, before the column names.
149  
150 =item C<headrow>
151  
152 The line containing the names of the columns.
153  
154 =item C<headline>
155  
156 The decoration line separating the column names from the data lines.
157  
158 =item C<rowline>
159  
160 The decoration line separating one data line from the next. I<Hidden
161 by default>.
162  
163 =item C<lastline>
164  
165 The very last decoration line, after all the data.
166  
167 =back
168  
169 Note: C<t.hide('headrow');t.hide('headline')> will cause I<both>
170 features to be hidden. See L</show>.
171  
172 =cut
173  
174 4 ▶sub hide {
Subroutine hide: called CC=3 SCAR=12.3
Pod documented
175 4 my ($self,@what)=@_;
176 4 ▶ if (@what==1 and ref($what[0]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (@what == 1 and ref $what[0] eq "ARRAY") 0 4 4
Condition33%1/3
@what == 1 and ref $what[0] eq "ARRAY"
!ll&&!rl&&r
040
MC/DC0%0/2
@what == 1 and ref $what[0] eq "ARRAY"
@what == 1 ref $what[0] eq "ARRAY"
Truth table33%1/3
A and B
A= @what == 1B= ref $what[0] eq "ARRAY"
ABresult
0X0
100
111
177 0 @what=@{$what[0]};
178 }
179 4 @{$self->{hide}}{grep {m{(headrow)|((head|first|last|row)line)}} map {lc $_} @what}=();
180 4 return;
181 }
182  
183 =head2 C<show>
184  
185 This parameter does the opposite of C<hide>: sets the given features
186 to be shown.
187  
188 Note: C<t.show('headrow');t.show('headline')> will cause I<both>
189 features to be shown. See L</hide>.
190  
191 =cut
192  
193 3 ▶sub show {
Subroutine show: called CC=3 SCAR=12.3
Pod documented
194 3 my ($self,@what)=@_;
195 3 ▶ if (@what==1 and ref($what[0]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (@what == 1 and ref $what[0] eq "ARRAY") 0 3 3
Condition33%1/3
@what == 1 and ref $what[0] eq "ARRAY"
!ll&&!rl&&r
030
MC/DC0%0/2
@what == 1 and ref $what[0] eq "ARRAY"
@what == 1 ref $what[0] eq "ARRAY"
Truth table33%1/3
A and B
A= @what == 1B= ref $what[0] eq "ARRAY"
ABresult
0X0
100
111
196 0 @what=@{$what[0]};
197 }
198 3 delete @{$self->{hide}}{grep {m{(head(row|line))|((first|last|row)line)}} map {lc $_} @what};
199 3 return;
200 }
201  
202 =head2 C<errors>
203  
204 Setting this to a true value will set the C<reportErrors> option (see
205 L<Text::ASCIITable>).
206  
207 =cut
208  
209 0 ▶sub errors {
Subroutine errors: not called CC=1 SCAR=6.9
Pod documented
210 0 my ($self,$val)=@_;
211 0 $self->{errors}=$val;
212 0 return;
213 }
214  
215 =head2 C<allow>
216  
217 This parameter accepts a list of markup names to allow inside the
218 cells. This in needed to let C<Text::ASCIITable> calculate the correct
219 column widths. The recognized markups are:
220  
221 =over 4
222  
223 =item C<ansi>
224  
225 This will allow you to use ANSI escape sequences for things like
226 colors or baldface. This usually works only if you output to a
227 compliant terminal.
228  
229 =item C<html>
230  
231 This will allow you to use HTML tags. No check is performed on the
232 well-formedness of any such tag.
233  
234 =back
235  
236 Note: C<t.allow('html');t.allow('ansi')> will cause I<both>
237 markups to be recognized. See L</deny>.
238  
239 =cut
240  
241 2 ▶sub allow {
Subroutine allow: called CC=3 SCAR=12.3
Pod documented
242 2 my ($self,@what)=@_;
243 2 ▶ if (@what==1 and ref($what[0]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (@what == 1 and ref $what[0] eq "ARRAY") 0 2 2
Condition33%1/3
@what == 1 and ref $what[0] eq "ARRAY"
!ll&&!rl&&r
020
MC/DC0%0/2
@what == 1 and ref $what[0] eq "ARRAY"
@what == 1 ref $what[0] eq "ARRAY"
Truth table33%1/3
A and B
A= @what == 1B= ref $what[0] eq "ARRAY"
ABresult
0X0
100
111
244 0 @what=@{$what[0]};
245 }
246 2 @{$self->{allow}}{grep {m{ansi|html}} map {lc $_} @what}=();
247 2 return;
248 }
249  
250 =head2 C<deny>
251  
252 This parameter does the opposite of C<allow>: ignores the given
253 markups inside cells, counting them as data.
254  
255 Note: C<t.deny('html');t.deny('ansi')> will cause I<both>
256 markups to be ignored. See L</allow>.
257  
258 =cut
259  
260 1 ▶sub deny {
Subroutine deny: called CC=3 SCAR=12.3
Pod documented
261 1 my ($self,@what)=@_;
262 1 ▶ if (@what==1 and ref($what[0]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (@what == 1 and ref $what[0] eq "ARRAY") 0 1 1
Condition33%1/3
@what == 1 and ref $what[0] eq "ARRAY"
!ll&&!rl&&r
010
MC/DC0%0/2
@what == 1 and ref $what[0] eq "ARRAY"
@what == 1 ref $what[0] eq "ARRAY"
Truth table33%1/3
A and B
A= @what == 1B= ref $what[0] eq "ARRAY"
ABresult
0X0
100
111
263 0 @what=@{$what[0]};
264 }
265 1 delete @{$self->{allow}}{grep {m{ansi|html}} map {lc $_} @what};
266 1 return;
267 }
268  
269 =head2 C<alignHeadRow>
270  
271 Sets the alignment for the column names. Can be one of:
272  
273 =over 4
274  
275 =item *
276  
277 left
278  
279 =item *
280  
281 right
282  
283 =item *
284  
285 center
286  
287 =item *
288  
289 auto
290  
291 =back
292  
293 =cut
294  
295 0 ▶sub alignHeadRow {
Subroutine alignHeadRow: not called CC=1 SCAR=6.9
Pod documented
296 0 my ($self,$val)=@_;
297 0 $self->{headrow}=$val;
298 0 return;
299 }
300  
301 11 ▶sub _handleCols {
Subroutine _handleCols: called CC=5 SCAR=16.1
302 11 my ($self,@colspec)=@_;
303 11 ▶ if (@colspec==1 and ref($colspec[0]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (@colspec == 1 and ref $colspec[0] eq "ARRAY") 1 10 11
Condition100%3/3
@colspec == 1 and ref $colspec[0] eq "ARRAY"
!ll&&!rl&&r
911
MC/DC100%2/2
@colspec == 1 and ref $colspec[0] eq "ARRAY"
@colspec == 1 ref $colspec[0] eq "ARRAY"
Truth table100%3/3
A and B
A= @colspec == 1B= ref $colspec[0] eq "ARRAY"
ABresult
0X0
100
111
304 1 @colspec=@{$colspec[0]};
305 }
306 11 my %colpos=();
307 11 my @cols=();
308 11 for (@colspec) {
309 30 ▶ if (ref $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_) { } 2 28 30
310 2 push @cols,{name=>$_->[0],
311 align=>$_->[1],
312 width=>$_->[2],
313 widen=>$_->[3],
314 nalign=>$_->[4],
315 };
316 2 $colpos{$_->[0]}=$#cols;
317 } else {
318 28 push @cols,{name=>$_};
319 28 $colpos{$_}=$#cols;
320 }
321 }
322 11 return (\@cols,\%colpos)
323 }
324  
325 =head2 C<cols>
326  
327 This parameter sets the names, and optionally some properties, of all
328 the columns in the table. To add columns to an existing table, use
329 the L</addCols> parameter (usually as a method).
330  
331 This parameter accepts a list of column specifications. Each
332 specification can be:
333  
334 =over 4
335  
336 =item a single string
337  
338 that becomes the name of the column, and width and alignment default
339 to 'auto'
340  
341 =item an array reference
342  
343 that contains, in order:
344  
345 =over 8
346  
347 =item *
348  
349 the name
350  
351 =item *
352  
353 the alignment for the data, one of 'left', 'right', 'center', 'auto' (see
354 L<Text::ASCIITable/alignCol>)
355  
356 =item *
357  
358 the maximum width of the column, in characters (see
359 L<Text::ASCIITable/setColWidth>)
360  
361 =item *
362  
363 whether to force the width of the column, a boolean (see
364 L<Text::ASCIITable/setColWidth>, the last parameter)
365  
366 =item *
367  
368 the name alignment (see L<Text::ASCIITable/alignColName>)
369  
370 =back
371  
372 =back
373  
374 Note: this sets I<all of the columns>. C<t.cols('a','b');t.cols('c')>
375 will result in a table with I<only 1> column. See L</addCols>.
376  
377 =cut
378  
379 10 ▶sub cols {
Subroutine cols: called CC=1 SCAR=0.0
Pod documented
380 10 my $self=shift;
381 10 ($self->{cols},$self->{colpos})=$self->_handleCols(@_);
382 10 return;
383 }
384  
385 =head2 C<addCols>
386  
387 This parameter works like C<cols>, but adds the given columns to the
388 existing ones, instead of replacing them. So
389 C<t.cols('a','b');t.addCols('c')> will result in a table with 3 columns.
390  
391 =cut
392  
393 1 ▶sub addCols {
Subroutine addCols: called CC=1 SCAR=0.0
Pod documented
394 1 my $self=shift;
395 1 my ($cols,$colpos)=$self->_handleCols(@_);
396 1 push @{$self->{cols}},@$cols;
397 1 @{$self->{colpos}}{keys %$colpos}=values %$colpos;
398 1 return;
399 }
400  
401 =head2 C<rows>
402  
403 This parameter accepts a list of array references, one per row. Each
404 row must have one scalar element per each column that will be
405 produced.
406  
407 Note that, because of the way this plugin works, you can do something
408 like:
409  
410 [% USE t=ASCIITable(cols=>['a','b']);
411 t.rows([1,2,3],[4,5,6]);
412 t.addCols('c');
413 t.draw() %]
414  
415 And it will print a 3x2 table.
416  
417 Note: this sets I<all of the rows>.
418 C<t.rows([1,2,3],[4,5,6]);t.rows([7,8,9])>
419 will result in a table with I<only 1> row. See L</addRows>.
420  
421 =cut
422  
423 9 ▶sub rows {
Subroutine rows: called CC=3 SCAR=13.5
Pod documented
424 9 my ($self,@rows)=@_;
425 9 ▶ if (@rows==1 and ref($rows[0]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (@rows == 1 and ref $rows[0] eq "ARRAY") 0 9 9
Condition33%1/3
@rows == 1 and ref $rows[0] eq "ARRAY"
!ll&&!rl&&r
900
MC/DC0%0/2
@rows == 1 and ref $rows[0] eq "ARRAY"
@rows == 1 ref $rows[0] eq "ARRAY"
Truth table33%1/3
A and B
A= @rows == 1B= ref $rows[0] eq "ARRAY"
ABresult
0X0
100
111
426 0 @rows=@{$rows[0]};
427 }
428 9 $self->{rows}=[@rows];
429 9 return;
430 }
431  
432 =head2 C<addRows>
433  
434 This parameter works like C<rows>, but adds the given rows to the
435 existing ones, instead of replacing them. So
436 C<t.rows([1,2,3],[4,5,6]);t.addRows([7,8,9])>
437 will result in a table with 3 rows.
438  
439 =cut
440  
441 2 ▶sub addRows {
Subroutine addRows: called CC=3 SCAR=11.4
Pod documented
442 2 my ($self,@row)=@_;
443 2 ▶ if (@row==1 and ref($row[0]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (@row == 1 and ref $row[0] eq "ARRAY") 2 0 2
Condition33%1/3
@row == 1 and ref $row[0] eq "ARRAY"
!ll&&!rl&&r
002
MC/DC0%0/2
@row == 1 and ref $row[0] eq "ARRAY"
@row == 1 ref $row[0] eq "ARRAY"
Truth table33%1/3
A and B
A= @row == 1B= ref $row[0] eq "ARRAY"
ABresult
0X0
100
111
444 2 @row=@{$row[0]};
445 }
446 2 push @{$self->{rows}},[@row];
447 2 return;
448 }
449  
450 1 my %styles=(
451 'default'=>
452 {lines=>undef,
453 globals=>{hide=>'rowline'},
454 },
455 'rest-simple'=>
456 {lines=>[
457 ['<','>','=',' '],
458 ['<','>',' '],
459 ['<','>','=',' '],
460 ['<','>',' '],
461 ['<','>','=',' '],
462 ['<','>','-',' '],
463 1,1,
464 ],
465 globals=>{hide=>'rowline'},
466 },
467 'rest-grid'=>
468 {lines=>[
469 ['+','+','-','+'],
470 ['|','|','|'],
471 ['+','+','=','+'],
472 ['|','|','|'],
473 ['+','+','-','+'],
474 ['+','+','-','+'],
475 0,0,
476 ],
477 globals=>{show=>'rowline'},
478 },
479 );
480  
481 =head2 C<style>
482  
483 This parameter sets the draw style for the table. You can set it to a
484 list of array references, or to a style name.
485  
486 If you pass it a list, it can have 5, 6, or 8 elements. The first 6
487 elements are interpreted in the same way as the parameters of
488 C<Text::ASCIITable::draw> (see L<Text::ASCIITable/Custom tables>). The
489 last two, which default to 0, are the number of columns to remove on
490 the left- and right-hand side of the generated table; this is used to
491 have tables without vertical borders.
492  
493 If you pass it a style name, it must be one of the following:
494  
495 =over 4
496  
497 =item C<default>
498  
499 this is the default C<Text::ASCIITable> style:
500  
501 .--------------------------.
502 | one | two | three | four |
503 +-----+-----+-------+------+
504 | one | one | one | one |
505 | two | two | two | two |
506 '-----+-----+-------+------'
507  
508 =item C<rest-simple>
509  
510 this is the "simple table" style as used in reStructuredText:
511  
512 ===== ===== ======= ======
513 one two three four
514 ===== ===== ======= ======
515 one one one one
516 two two two two
517 ===== ===== ======= ======
518  
519 If you give C<show('rowline')> you get:
520  
521 ===== ===== ======= ======
522 one two three four
523 ===== ===== ======= ======
524 one one one one
525 ----- ----- ------- ------
526 two two two two
527 ===== ===== ======= ======
528  
529 Note that there is no blank space on either side.
530  
531 =item C<rest-grid>
532  
533 this is the "grid table" style as used in reStructuredText:
534  
535 +-----+-----+-------+------+
536 | one | two | three | four |
537 +=====+=====+=======+======+
538 | one | one | one | one |
539 +-----+-----+-------+------+
540 | two | two | two | two |
541 +-----+-----+-------+------+
542  
543 =back
544  
545 =cut
546  
547 5 ▶sub style {
Subroutine style: called CC=6 SCAR=22.9
Pod documented
548 5 my ($self,$style)=@_;
549 5 ▶ if (ref $style eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $style eq 'ARRAY') { } 1 4 5
elsif (exists $styles{lc $style}) { } 4 0 4
550 1 ▶ if (@$style==6) {
Branch: 3 branches
BranchTrueFalseTotal
if (@$style == 6) { } 1 0 1
elsif (@$style == 5) { } 0 0 0
elsif (@$style == 8) { } 0 0 0
551 1 $self->{style}=[@$style,0,0]
552 } elsif (@$style==5) {
553 0 $self->{style}=[@$style,[],0,0]
554 } elsif (@$style==8) {
555 0 $self->{style}=[@$style]
556 } else {
557 0 _die('Wrong style specification')
558 }
559 } elsif (exists $styles{lc $style}) {
560 4 $self->{style}=$styles{lc $style}->{lines};
561 4 $self->handleParms(%{$styles{lc $style}->{globals}});
562 } else {
563 0 _die("No such style $style");
564 }
565 }
566  
567 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=3 SCAR=24.8
568 0 ▶ return if $AUTOLOAD=~/:?DESTROY$/;
Branch: 1 branch
BranchTrueFalseTotal
if $AUTOLOAD =~ /:?DESTROY$/ 0 0 0
569 0 ▶ if (exists $paramSubs{lc($AUTOLOAD)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $paramSubs{lc $AUTOLOAD}) { } 0 0 0
570 0 goto &{$paramSubs{lc($AUTOLOAD)}};
571 } else {
572 0 _die("no such method $AUTOLOAD")
573 }
574 }
575  
576 10 ▶sub _globals {
Subroutine _globals: called CC=10 SCAR=23.8
577 10 my ($self)=@_;
578 10 my @ret=();
579 10 ▶ push @ret,'hide_HeadRow',1 if exists $self->{hide}{headrow};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"hide"}{"headrow"} 0 10 10
580 10 ▶ push @ret,'hide_HeadLine',1 if exists $self->{hide}{headline};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"hide"}{"headline"} 0 10 10
581 10 ▶ push @ret,'hide_FirstLine',1 if exists $self->{hide}{firstline};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"hide"}{"firstline"} 1 9 10
582 10 ▶ push @ret,'hide_LastLine',1 if exists $self->{hide}{lastline};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"hide"}{"lastline"} 0 10 10
583 10 ▶ push @ret,'allowANSI',1 if exists $self->{allow}{ansi};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"allow"}{"ansi"} 0 10 10
584 10 ▶ push @ret,'allowHTML',1 if exists $self->{allow}{html};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"allow"}{"html"} 1 9 10
585 10 ▶ push @ret,'reportErrors',$self->{errors} if $self->{errors};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"errors"} 0 10 10
586 10 ▶ push @ret,'alignHeadRow',$self->{headrow} if $self->{headrow};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"headrow"} 0 10 10
587 10 ▶ push @ret,'drawRowLine',1 unless exists $self->{hide}{rowline};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"hide"}{"rowline"} 3 7 10
588 10 return @ret;
589 }
590  
591 10 ▶sub _colprops {
Subroutine _colprops: called CC=1 SCAR=0.0
592 10 my ($self)=@_;
593 10 return @{$self->{cols}};
594 }
595 10 ▶sub _colnames {
Subroutine _colnames: called CC=1 SCAR=0.0
596 10 my ($self)=@_;
597 10 return map {$_->{name}} @{$self->{cols}};
598 }
599 10 ▶sub _rows {
Subroutine _rows: called CC=2 SCAR=7.1
600 10 my ($self)=@_;
601 10 ▶ return ($self->{rows}?@{$self->{rows}}:());
Branch: 1 branch
BranchTrueFalseTotal
$self->{'rows'} ? : 10 0 10
602 }
603  
604 10 ▶sub _style {
Subroutine _style: called CC=2 SCAR=6.9
605 10 my ($self)=@_;
606 10 ▶ return ($self->{style}?@{$self->{style}}[0..5]:());
Branch: 1 branch
BranchTrueFalseTotal
$self->{'style'} ? : 3 7 10
607 }
608 10 ▶sub _squeeze {
Subroutine _squeeze: called CC=2 SCAR=6.9
609 10 my ($self)=@_;
610 10 ▶ return ($self->{style}?@{$self->{style}}[6,7]:(0,0));
Branch: 1 branch
BranchTrueFalseTotal
$self->{'style'} ? : 3 7 10
611 }
612  
613 0 ▶sub _die {
Subroutine _die: not called CC=1 SCAR=6.9
614 0 die (Template::Exception->new('ASCIITable',$_[0]))
615 }
616  
617 =head1 TODO
618  
619 Better tests?
620  
621 =head1 BUGS
622  
623 None known so far. If you find any, please report them using
624 rt.cpan.org or e-mail. It would be great if you could provide a simple
625 test case that exercises the bug.
626  
627 =head1 COPYRIGHT AND LICENSE
628  
629 Copyright (C) 2005 dakkar <dakkar@thenautilus.net>
630  
631 This program is free software; you can redistribute it and/or modify it
632 under the same terms as Perl itself.
633  
634 1;
↑ Summary