XLS.pm

filter: Statementstmt 36.7% 18 / 49 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 71.4% 5 / 7 Podpod 100% 1 / 1 totaltotal 26.3% 24 / 91 CC 15 SCAR 40.5
CC
15
Cov
23%
_exceltotext
90.0
gather_data_from_file
56.0
BEGIN
1.0
CRAP 57.5
↑ Summary DOC.pm »
1 package Plucene::SearchEngine::Index::XLS;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 our $VERSION = '0.001'; # VERSION
5 # ABSTRACT: a Plucene backend for indexing Microsoft Excel spreadsheets
6  
7 1 ▶use parent qw(Plucene::SearchEngine::Index::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 __PACKAGE__->register_handler('application/xls', '.xls');
10 1 ▶use File::Temp qw/tmpnam/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Spreadsheet::ParseExcel;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14  
15 0 ▶sub gather_data_from_file {
Subroutine gather_data_from_file: not called CC=7 SCAR=40.3
Pod documented
16 0 my ($self, $file) = @_;
17 0 ▶ return unless $file =~ m/\.xls$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ /\.xls$/ 0 0 0
18  
19 0 ▶ if ($file =~ m/\.xls$/) { # Process only xls file data.
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /\.xls$/) 0 0 0
20 0 my $txtfile = tmpnam();
21 0 _exceltotext($file, $txtfile);
22 0 $file = $txtfile;
23 }
24 0 my $in;
25 0 ▶ if (exists $self->{encoding}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{'encoding'}) { } 0 0 0
26 0 my $encoding = $self->{encoding}{data}[0];
27 0 ▶ open $in, "<:encoding($encoding)", $file
Branch: 1 branch
BranchTrueFalseTotal
open $in, "<:encoding($encoding)", $file or die "Couldn't open ${file}: $!" 0 0 0
28 or die "Couldn't open $file: $!";
29 } else {
30 0 ▶ open $in, '<', $file
Branch: 1 branch
BranchTrueFalseTotal
open $in, "<", $file or die "Couldn't open ${file}: $!" 0 0 0
31 or die "Couldn't open $file: $!";
32 }
33 0 ▶ while (<$in>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $in)) 0 0 0
34 0 $self->add_data('text' => 'UnStored' => $_);
35 }
36 0 unlink $file; #Remove the text file, part of maintenance.
37 0 return $self;
38 }
39  
40 0 ▶sub _exceltotext {
Subroutine _exceltotext: not called CC=9 SCAR=45.0
41 ##This is the standard code taken from SpreadSheet::ParseExcel Module.
42 0 my $excel = shift;
43 0 my $output = shift;
44  
45 0 my $oExcel = Spreadsheet::ParseExcel->new();
46 0 ▶ open my $txt_out, '>', $output or die "Not able to open file : $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $txt_out, ">", $output or die "Not able to open file : $!" 0 0 0
47  
48 0 my $oBook = $oExcel->Parse($excel);
49  
50 0 print $txt_out "FILE :", $oBook->{File} , "\n";
51 0 print $txt_out "COUNT :", $oBook->{SheetCount} , "\n";
52  
53 print $txt_out "AUTHOR:", $oBook->{Author} , "\n"
54 0 ▶ if defined $oBook->{Author};
Branch: 1 branch
BranchTrueFalseTotal
if defined $oBook->{"Author"} 0 0 0
55  
56 0 ▶ for(my $iSheet=0; $iSheet < $oBook->{SheetCount} ; $iSheet++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iSheet < $oBook->{"SheetCount"}) 0 0 0
57 0 my $oWkS = $oBook->{Worksheet}[$iSheet];
58 0 print OUTPUT $oWkS->{Name}, "\n";
59 0 ▶ for(my $iR = $oWkS->{MinRow} ;
Branch: 1 branch
BranchTrueFalseTotal
if (defined $oWkS->{"MaxRow"} and $iR <= $oWkS->{"MaxRow"}) 0 0 0
Condition0%0/3
defined $oWkS->{"MaxRow"} and $iR <= $oWkS->{"MaxRow"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $oWkS->{"MaxRow"} and $iR <= $oWkS->{"MaxRow"}
defined $oWkS->{"MaxRow"} $iR <= $oWkS->{"MaxRow"}
Truth table0%0/3
A and B
A= defined $oWkS->{"MaxRow"}B= $iR <= $oWkS->{"MaxRow"}
ABresult
0X0
100
111
60 defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ;
61 $iR++)
62 {
63 0 ▶ for(my $iC = $oWkS->{MinCol} ;
Branch: 1 branch
BranchTrueFalseTotal
if (defined $oWkS->{"MaxCol"} and $iC <= $oWkS->{"MaxCol"}) 0 0 0
Condition0%0/3
defined $oWkS->{"MaxCol"} and $iC <= $oWkS->{"MaxCol"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $oWkS->{"MaxCol"} and $iC <= $oWkS->{"MaxCol"}
defined $oWkS->{"MaxCol"} $iC <= $oWkS->{"MaxCol"}
Truth table0%0/3
A and B
A= defined $oWkS->{"MaxCol"}B= $iC <= $oWkS->{"MaxCol"}
ABresult
0X0
100
111
64 defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ;
65 $iC++)
66 {
67 0 my $oWkC = $oWkS->{Cells}[$iR][$iC];
68 0 ▶ print OUTPUT $oWkC->Value, "\n" if($oWkC);
Branch: 1 branch
BranchTrueFalseTotal
if $oWkC 0 0 0
69 }
70 }
71 }
72 0 close($txt_out);
73 }
74  
75 1 1;
76  
77 __END__
↑ Summary DOC.pm »