| 1 | package CPAN::Testers::WWW::Statistics::Excel; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 9 | $VERSION = '0.06'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 NAME | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | CPAN::Testers::WWW::Statistics::Excel - CPAN Testers Statistics Excel tool. | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | my %hash = { logfile => 'my.log' }; | ||||||||||||||||||||||||||||
| 18 | my $ct = CPAN::Testers::WWW::Statistics::Excel->new(%hash); | ||||||||||||||||||||||||||||
| 19 | $ct->create( source => $source, target => $target ); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | Using previously formatted data, generate Excel format files. | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =cut | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 28 | # Library Modules | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 9 | ▶ | use base qw(Class::Accessor::Fast); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 9 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 9 | ▶ | use File::Path; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 9 | ▶ | use HTML::Entities; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | 9 | ▶ | use HTML::TokeParser; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | 9 | ▶ | use IO::File; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 37 | 9 | ▶ | use Spreadsheet::WriteExcel; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 40 | # Variables | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 9 | my %format_config = ( | |||||||||||||||||||||||||||
| 43 | head => { border => 1, pattern => 1, color => 'black', bg_color => 'gray', bold => 1 }, | ||||||||||||||||||||||||||||
| 44 | lots => { border => 1, pattern => 1, color => 'black', bg_color => 'green', align => 'right' }, | ||||||||||||||||||||||||||||
| 45 | more => { border => 1, pattern => 1, color => 'black', bg_color => 'lime', align => 'right' }, | ||||||||||||||||||||||||||||
| 46 | some => { border => 1, pattern => 1, color => 'black', bg_color => 'yellow', align => 'right' }, | ||||||||||||||||||||||||||||
| 47 | none => { border => 1, pattern => 1, color => 'black', bg_color => 'silver', align => 'center', valign => 'middle' }, | ||||||||||||||||||||||||||||
| 48 | totals => { border => 1, pattern => 1, color => 'white', bg_color => 'black', bold => 1 }, | ||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 52 | # Subroutines | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head1 INTERFACE | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =head2 The Constructor | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | =over 4 | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =item * new | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | Object constructor. Takes an optional hash, which can contain initial settings | ||||||||||||||||||||||||||||
| 63 | for log file creation: | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | logfile - path to log file | ||||||||||||||||||||||||||||
| 66 | logclean - append (0) or overwrite/create (1) | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =back | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =cut | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 6 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 6 | my $class = shift; | |||||||||||||||||||||||||||
| 74 | 6 | my %hash = @_; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 6 | my $self = {}; | |||||||||||||||||||||||||||
| 77 | 6 | bless $self, $class; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 6 | ▶ | $self->logfile( $hash{logfile} || '' ); | ||||||||||||||||||||||||||
|
Condition100%2/2
$hash{'logfile'} || ''
MC/DC100%1/1
$hash{'logfile'} || ''
$hash{'logfile'}
Truth table100%2/2
A
A= $hash{'logfile'}
| |||||||||||||||||||||||||||||
| 80 | 6 | ▶ | $self->logclean( $hash{logclean} || 0 ); | ||||||||||||||||||||||||||
|
Condition100%2/2
$hash{'logclean'} || 0
MC/DC100%1/1
$hash{'logclean'} || 0
$hash{'logclean'}
Truth table100%2/2
A
A= $hash{'logclean'}
| |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 6 | $self->_log("logfile =" . $self->logfile ); | |||||||||||||||||||||||||||
| 83 | 6 | $self->_log("logclean =" . $self->logclean ); | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 6 | return $self; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head2 Methods | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =over 4 | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =item * create | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | Method to facilitate the creation of an Excel file. | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Parameter values are contained within a hash to the method: | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | source - path to source HTML containing table | ||||||||||||||||||||||||||||
| 99 | target - path to target Excel format file | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | In addition the following hash values can also be passed: | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | title - title for the file (Excel property) | ||||||||||||||||||||||||||||
| 104 | author - author of the file (Excel property) | ||||||||||||||||||||||||||||
| 105 | comments - comments string (Excel property) | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | =item * logfile | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | Accessor for the path to the file to use for log messages. If no path is given | ||||||||||||||||||||||||||||
| 110 | either via this method or through the constructor, no log messages are printed. | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =item * logclean | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | Accessor for log creation. If a false value will append log messages, | ||||||||||||||||||||||||||||
| 115 | otherwise will overwrite any existing logfile. | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =back | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 9 | __PACKAGE__->mk_accessors( qw( logfile logclean ) ); | |||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 5 | ▶ | sub create { | ||||||||||||||||||||||||||
|
Subroutine
create: called CC=41 SCAR=37.1
Pod
documented
| |||||||||||||||||||||||||||||
| 125 | 5 | my $self = shift; | |||||||||||||||||||||||||||
| 126 | 5 | my %hash = @_; | |||||||||||||||||||||||||||
| 127 | 5 | my %opt; | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 5 | $self->_log("start"); | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 5 | ▶ | die "Source file not provided\n" unless( $hash{source}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | 4 | ▶ | die "Target file not provided\n" unless( $hash{target}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 3 | ▶ | die "Source file [$hash{source}] not found\n" unless(-f $hash{source}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 2 | mkpath(dirname($hash{target})); | |||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 2 | my $workbook = Spreadsheet::WriteExcel->new( $hash{target} ); | |||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 2 | $workbook->set_custom_color(23, '#999999'); # head | |||||||||||||||||||||||||||
| 139 | 2 | $workbook->set_custom_color(17, '#00ff00'); # lots | |||||||||||||||||||||||||||
| 140 | 2 | $workbook->set_custom_color(11, '#99ff99'); # more | |||||||||||||||||||||||||||
| 141 | 2 | $workbook->set_custom_color(13, '#ddffdd'); # some | |||||||||||||||||||||||||||
| 142 | 2 | $workbook->set_custom_color(22, '#dddddd'); # none | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | # Add and define a format | ||||||||||||||||||||||||||||
| 145 | 2 | my %formats; | |||||||||||||||||||||||||||
| 146 | 2 | for my $format (keys %format_config) { | |||||||||||||||||||||||||||
| 147 | 12 | my $class = $workbook->add_format( %{ $format_config{$format} } ); # Add a format | |||||||||||||||||||||||||||
| 148 | 12 | $formats{$format} = $class; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 2 | my $worksheet = $workbook->add_worksheet(); | |||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 2 | my $cell = {}; | |||||||||||||||||||||||||||
| 154 | 2 | my ($title,$table,$row,$col) = (0,0,0,0); | |||||||||||||||||||||||||||
| 155 | 2 | my $p = HTML::TokeParser->new( $hash{source}, %opt ); | |||||||||||||||||||||||||||
| 156 | 2 | ▶ | while(my $token = $p->get_token) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | # if no title given, use the H2 tag. | ||||||||||||||||||||||||||||
| 159 | 36232 | ▶ | unless($table || $hash{title}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$table or $hash{"title"}
MC/DC100%2/2
$table or $hash{"title"}
$table
$hash{"title"}
Truth table100%3/3
A or B
A= $tableB= $hash{"title"}
| |||||||||||||||||||||||||||||
| 160 | 192 | ▶ | if($token->[0] eq 'S' && $token->[1] eq 'h2') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$token->[0] eq "S" and $token->[1] eq "h2"
MC/DC100%2/2
$token->[0] eq "S" and $token->[1] eq "h2"
$token->[0] eq "S"
$token->[1] eq "h2"
Truth table100%3/3
A and B
A= $token->[0] eq "S"B= $token->[1] eq "h2"
| |||||||||||||||||||||||||||||
| 161 | 1 | $title = 1; | |||||||||||||||||||||||||||
| 162 | 1 | $cell = {text => ''}; | |||||||||||||||||||||||||||
| 163 | 1 | next; | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | 191 | ▶ | if($token->[0] eq 'E' && $token->[1] eq 'h2') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$token->[0] eq "E" and $token->[1] eq "h2"
MC/DC100%2/2
$token->[0] eq "E" and $token->[1] eq "h2"
$token->[0] eq "E"
$token->[1] eq "h2"
Truth table100%3/3
A and B
A= $token->[0] eq "E"B= $token->[1] eq "h2"
| |||||||||||||||||||||||||||||
| 166 | 1 | $title = 0; | |||||||||||||||||||||||||||
| 167 | 1 | $hash{title} = decode_entities($cell->{text}); | |||||||||||||||||||||||||||
| 168 | 1 | $self->_log("TITLE: '$cell->{text}'"); | |||||||||||||||||||||||||||
| 169 | 1 | next; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | 190 | ▶ | if($title && $token->[0] eq 'T') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$title and $token->[0] eq "T"
MC/DC50%1/2
$title and $token->[0] eq "T"
$title
$token->[0] eq "T"
Truth table66%2/3
A and B
A= $titleB= $token->[0] eq "T"
| |||||||||||||||||||||||||||||
| 172 | 1 | ▶ | $cell->{text} .= "\n" if($cell->{text}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 1 | $cell->{text} .= $token->[1]; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 36230 | ▶ | next unless($table || $token->[1] eq 'table'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$table or $token->[1] eq "table"
MC/DC100%2/2
$table or $token->[1] eq "table"
$table
$token->[1] eq "table"
Truth table100%3/3
A or B
A= $tableB= $token->[1] eq "table"
| |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 36002 | ▶ | if($token->[0] eq 'S' && $token->[1] eq 'table') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$token->[0] eq "S" and $token->[1] eq "table"
MC/DC100%2/2
$token->[0] eq "S" and $token->[1] eq "table"
$token->[0] eq "S"
$token->[1] eq "table"
Truth table100%3/3
A and B
A= $token->[0] eq "S"B= $token->[1] eq "table"
| |||||||||||||||||||||||||||||
| 180 | 2 | $table = 1; | |||||||||||||||||||||||||||
| 181 | 2 | next; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | 36000 | ▶ | if($token->[0] eq 'E' && $token->[1] eq 'table') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$token->[0] eq "E" and $token->[1] eq "table"
MC/DC100%2/2
$token->[0] eq "E" and $token->[1] eq "table"
$token->[0] eq "E"
$token->[1] eq "table"
Truth table100%3/3
A and B
A= $token->[0] eq "E"B= $token->[1] eq "table"
| |||||||||||||||||||||||||||||
| 184 | 2 | $table = 0; | |||||||||||||||||||||||||||
| 185 | 2 | last; | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 35998 | ▶ | if($token->[0] eq 'S' && $token->[1] eq 'tr') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$token->[0] eq "S" and $token->[1] eq "tr"
MC/DC100%2/2
$token->[0] eq "S" and $token->[1] eq "tr"
$token->[0] eq "S"
$token->[1] eq "tr"
Truth table100%3/3
A and B
A= $token->[0] eq "S"B= $token->[1] eq "tr"
| |||||||||||||||||||||||||||||
| 189 | 129 | $col = 0; | |||||||||||||||||||||||||||
| 190 | 129 | next; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | 35869 | ▶ | if($token->[0] eq 'E' && $token->[1] eq 'tr') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$token->[0] eq "E" and $token->[1] eq "tr"
MC/DC100%2/2
$token->[0] eq "E" and $token->[1] eq "tr"
$token->[0] eq "E"
$token->[1] eq "tr"
Truth table100%3/3
A and B
A= $token->[0] eq "E"B= $token->[1] eq "tr"
| |||||||||||||||||||||||||||||
| 193 | 129 | $row++; | |||||||||||||||||||||||||||
| 194 | 129 | next; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 35740 | ▶ | if($token->[0] eq 'S' && $token->[1] eq 'th') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$token->[0] eq "S" and $token->[1] eq "th"
MC/DC100%2/2
$token->[0] eq "S" and $token->[1] eq "th"
$token->[0] eq "S"
$token->[1] eq "th"
Truth table100%3/3
A and B
A= $token->[0] eq "S"B= $token->[1] eq "th"
| |||||||||||||||||||||||||||||
| 198 | 1116 | $cell = { class => 'head', text => '' }; | |||||||||||||||||||||||||||
| 199 | 1116 | ▶ | if($token->[2]->{class}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 550 | $cell = { class => $token->[2]->{class}, text => '' }; | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | 1116 | next; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | 34624 | ▶ | if($token->[0] eq 'E' && $token->[1] eq 'th') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$token->[0] eq "E" and $token->[1] eq "th"
MC/DC100%2/2
$token->[0] eq "E" and $token->[1] eq "th"
$token->[0] eq "E"
$token->[1] eq "th"
Truth table100%3/3
A and B
A= $token->[0] eq "E"B= $token->[1] eq "th"
| |||||||||||||||||||||||||||||
| 205 | # write cell | ||||||||||||||||||||||||||||
| 206 | 1116 | $self->_log("CELL: TH: [$row/$col] $cell->{class} '$cell->{text}'"); | |||||||||||||||||||||||||||
| 207 | 1116 | $worksheet->write($row, $col, decode_entities($cell->{text}), $formats{$cell->{class}}); | |||||||||||||||||||||||||||
| 208 | 1116 | $col++; | |||||||||||||||||||||||||||
| 209 | 1116 | next; | |||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 33508 | ▶ | if($token->[0] eq 'S' && $token->[1] eq 'td') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$token->[0] eq "S" and $token->[1] eq "td"
MC/DC100%2/2
$token->[0] eq "S" and $token->[1] eq "td"
$token->[0] eq "S"
$token->[1] eq "td"
Truth table100%3/3
A and B
A= $token->[0] eq "S"B= $token->[1] eq "td"
| |||||||||||||||||||||||||||||
| 213 | 9075 | $cell = { class => 'none', text => '' }; | |||||||||||||||||||||||||||
| 214 | 9075 | ▶ | if($token->[2]->{class}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | 9075 | $cell = { class => $token->[2]->{class}, text => '' }; | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | 9075 | next; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | 24433 | ▶ | if($token->[0] eq 'E' && $token->[1] eq 'td') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$token->[0] eq "E" and $token->[1] eq "td"
MC/DC100%2/2
$token->[0] eq "E" and $token->[1] eq "td"
$token->[0] eq "E"
$token->[1] eq "td"
Truth table100%3/3
A and B
A= $token->[0] eq "E"B= $token->[1] eq "td"
| |||||||||||||||||||||||||||||
| 220 | # write cell | ||||||||||||||||||||||||||||
| 221 | 9075 | $self->_log("CELL: TD: [$row/$col] $cell->{class} '$cell->{text}'"); | |||||||||||||||||||||||||||
| 222 | 9075 | $worksheet->write($row, $col, decode_entities($cell->{text}), $formats{$cell->{class}}); | |||||||||||||||||||||||||||
| 223 | 9075 | $col++; | |||||||||||||||||||||||||||
| 224 | 9075 | next; | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 15358 | ▶ | if($token->[0] eq 'T') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 11566 | ▶ | $cell->{text} .= "\n" if($cell->{text}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | 11566 | $cell->{text} .= $token->[1]; | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 2 | ▶ | $hash{title} ||= 'CPAN Testers Matrix'; | ||||||||||||||||||||||||||
|
Condition100%2/2
$hash{"title"} ||= "CPAN Testers Matrix"
MC/DC100%1/1
$hash{"title"} ||= "CPAN Testers Matrix"
$hash{"title"}
Truth table100%2/2
A
A= $hash{"title"}
| |||||||||||||||||||||||||||||
| 234 | 2 | ▶ | $hash{author} ||= 'CPAN Testers'; | ||||||||||||||||||||||||||
|
Condition100%2/2
$hash{"author"} ||= "CPAN Testers"
MC/DC100%1/1
$hash{"author"} ||= "CPAN Testers"
$hash{"author"}
Truth table100%2/2
A
A= $hash{"author"}
| |||||||||||||||||||||||||||||
| 235 | 2 | ▶ | $hash{comments} ||= 'Copyright (C) 2009 The Perl Foundation'; | ||||||||||||||||||||||||||
|
Condition100%2/2
$hash{"comments"} ||= "Copyright (C) 2009 The Perl Foundation"
MC/DC100%1/1
$hash{"comments"} ||= "Copyright (C) 2009 The Perl Foundation"
$hash{"comments"}
Truth table100%2/2
A
A= $hash{"comments"}
| |||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 2 | $worksheet->set_landscape(); # Landscape mode | |||||||||||||||||||||||||||
| 238 | 2 | $worksheet->set_paper(9); # A4 | |||||||||||||||||||||||||||
| 239 | 2 | $worksheet->fit_to_pages(0, 1); # 1 page deep, many wide | |||||||||||||||||||||||||||
| 240 | 2 | $worksheet->set_header('&L&D&C'.$hash{title}.'&R&T'); | |||||||||||||||||||||||||||
| 241 | 2 | $worksheet->set_footer('&RPage &P of &N'); | |||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 2 | $worksheet->repeat_rows(0, 1); # Repeat the first two rows | |||||||||||||||||||||||||||
| 244 | 2 | $worksheet->repeat_columns(0, 1); # Repeat the first two columns | |||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | $workbook->set_properties( | ||||||||||||||||||||||||||||
| 248 | title => $hash{title}, | ||||||||||||||||||||||||||||
| 249 | author => $hash{author}, | ||||||||||||||||||||||||||||
| 250 | comments => $hash{comments}, | ||||||||||||||||||||||||||||
| 251 | 2 | ); | |||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | 2 | ▶ | $workbook->close() or die "Error closing file: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | 2 | $self->_log("finish"); | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 258 | # Private Methods | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 10215 | ▶ | sub _log { | ||||||||||||||||||||||||||
|
Subroutine
_log: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 261 | 10215 | my $self = shift; | |||||||||||||||||||||||||||
| 262 | 10215 | ▶ | my $log = $self->logfile or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 263 | 10 | ▶ | mkpath(dirname($log)) unless(-f $log); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 10 | ▶ | my $mode = $self->logclean ? 'w+' : 'a+'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 266 | 10 | $self->logclean(0); | |||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 10 | my @dt = localtime(time); | |||||||||||||||||||||||||||
| 269 | 10 | my $dt = sprintf "%04d/%02d/%02d %02d:%02d:%02d", $dt[5]+1900,$dt[4]+1,$dt[3],$dt[2],$dt[1],$dt[0]; | |||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 10 | ▶ | my $fh = IO::File->new($log,$mode) or die "Cannot write to log file [$log]: $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | 10 | print $fh "$dt ", @_, "\n"; | |||||||||||||||||||||||||||
| 273 | 10 | $fh->close; | |||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 9 | q('This module is dedicated to the Birmingham Perl Mongers'); | |||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | __END__ | ||||||||||||||||||||||||||||