Porf/examples/example_array.pl untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 50 CC 4 SCAR 25.1
CC
4
Cov
0%
run_example
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 12.3
1 # perl
2 #
3 # Report example, data rows given as array reference
4 #
5 # PORF Perl Open Report Framework
6 #
7 # Ralf Peine, Wed May 14 10:39:23 2014
8 #
9 #------------------------------------------------------------------------------
10  
11 use warnings;
12 use strict;
13  
14 use Report::Porf::Framework;
15  
16 sub run_example {
17 my $person_rows = shift; # Param1: Reference to list of arrays
18 my $format = shift; # Param2: Optional: format of report
19  
20 my $count_rows = scalar @{$person_rows};
21  
22 $format = 'text' unless $format;
23  
24 # --- create Report -------------------------------------------------------
25 my $report_frame_work = Report::Porf::Framework::get();
26 my $report_configurator = $report_frame_work->create_report_configurator($format);
27  
28 # $report->set_verbose(3); # uncomment to see infos about configuring phase
29  
30 # --- Configure Report ----------------------------------------------------
31  
32 $report_configurator->set_alternate_row_colors('#EEEEEE', '#FFFFFF', '#DDDDFF')
33 if $report_configurator->can ('set_alternate_row_colors');
34  
35 my $report = $report_configurator->create_and_configure_report();
36  
37 # store info about data columns
38 my $count_idx = 0;
39 my $prename_idx = 1;
40 my $surname_idx = 2;
41 my $age_idx = 3;
42 my $time_idx = 4;
43  
44 if ( lc($format) eq 'text') {
45 $report->set_header_row_start("@"); # overwrite default
46 $report->set_header_end (" @"); # overwrite default
47 }
48  
49 # --- configure table -----------------------------------
50
51 $report->configure_column(-header => 'Count', -align => 'Center', -value => sub { return $_[0]->[$count_idx ]; } );
52 $report->configure_column(-header => 'TimeStamp', -w => 16, -a => 'R', -format => "%.5e sec",
53 -color => "#CCEECC", -v => '$_[0]->['.$time_idx. ']' );
54 $report->configure_column(-h => 'Age', -w => 15, -a => 'R',
55 -f => "%.3f years", -value_indexed => $age_idx );
56 $report->configure_column(-h => 'Prename', -w => 11, -a => 'l', -val_idx => $prename_idx );
57 $report->configure_column(-h => 'Surname', -width => 8, -vi => $surname_idx );
58
59 $report->configure_complete();
60  
61 # --- print out table under own control -----------------------------------
62  
63 print($report->get_output_start());
64
65 foreach my $data (@{$person_rows}) {
66 print($report->get_row_output($data));
67 }
68
69 print($report->get_output_end());
70
71 # --- return count of entries ---------------------------
72  
73 return ($count_rows);
74 }
75  
76 1;