dbMan/Extension/SQLOutputHTML.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 60 CC 5 SCAR 19.5
CC
5
Cov
0%
done
12.0
handle_action
12.0
IDENTIFICATION
2.0
CRAP 7.0
1 package DBIx::dbMan::Extension::SQLOutputHTML;
2  
3 use strict;
4 use base 'DBIx::dbMan::Extension';
5  
6 our $VERSION = '0.06';
7  
8 1;
9  
10 sub IDENTIFICATION { return "000001-000028-000006"; }
11  
12 sub preference { return 0; }
13  
14 sub init {
15 my $obj = shift;
16 $obj->{-mempool}->register('output_format','html');
17 }
18  
19 sub done {
20 my $obj = shift;
21 $obj->{-mempool}->deregister('output_format','html');
22 if ($obj->{-mempool}->get('output_format') eq 'html') {
23 my @all_formats = $obj->{-mempool}->get_register('output_format');
24 $obj->{-mempool}->set('output_format', @all_formats ? $all_formats[0] : '');
25 }
26 }
27
28 sub known_actions { return [ qw/SQL_OUTPUT/ ]; }
29  
30 sub handle_action {
31 my ($obj,%action) = @_;
32  
33 $action{processed} = 1;
34 if ($action{action} eq 'SQL_OUTPUT') {
35 if ($obj->{-mempool}->get('output_format') eq 'html') {
36 my $output = "<TABLE>\n<TR>";
37 $output .= join '',map { "<TH>$_</TH>" } @{$action{fieldnames}};
38 $output .= "</TR>\n";
39 for (@{$action{result}}) {
40 $output .= "<TR>".(join '',map { "<TD>$_</TD>" } @$_);
41 $output .= "</TR>\n";
42 }
43 $output .= "</TABLE>\n";
44 $action{action} = 'OUTPUT';
45 $action{output} = $output;
46 delete $action{processed};
47 }
48 }
49  
50 return %action;
51 }