blib/lib/Search/Tools.pm

filter: Statementstmt 78.5% 44 / 56 Branchbran 50.0% 5 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 78.5% 11 / 14 Podpod 100% 7 / 7 totaltotal 73.9% 68 / 92 CC 7 SCAR 14.6
CC
7
Cov
72%
slurp
10.0
regexp
2.0
transliterate
2.0
CRAP 4.3
« blib/lib/Search/Tools/ArgNormalizer.pm ↑ Summary blib/lib/Search/Tools/Query.pm »
1 package Search::Tools;
2 41 ▶use 5.008_003;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 41 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 41 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 41 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 41 ▶use Scalar::Util qw( openhandle );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 41 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 41 our $VERSION = '1.007';
10  
11 41 ▶use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 41 XSLoader::load( 'Search::Tools', $VERSION );
13  
14 41 our $XS_DEBUG = 0;
15  
16 19 ▶sub parser {
Subroutine parser: called CC=1 SCAR=0.0
Pod documented
17 19 my $class = shift;
18 19 require Search::Tools::QueryParser;
19 19 return Search::Tools::QueryParser->new(@_);
20 }
21  
22 0 ▶sub regexp {
Subroutine regexp: not called CC=1 SCAR=6.9
Pod documented
23 0 my $class = shift;
24  
25 0 croak("as of version 0.24 you should use parser() instead of regexp()");
26 }
27  
28 11 ▶sub hiliter {
Subroutine hiliter: called CC=1 SCAR=0.0
Pod documented
29 11 my $class = shift;
30 11 require Search::Tools::HiLiter;
31 11 return Search::Tools::HiLiter->new(@_);
32 }
33  
34 6 ▶sub snipper {
Subroutine snipper: called CC=1 SCAR=0.0
Pod documented
35 6 my $class = shift;
36 6 require Search::Tools::Snipper;
37 6 return Search::Tools::Snipper->new(@_);
38 }
39  
40 0 ▶sub transliterate {
Subroutine transliterate: not called CC=1 SCAR=6.9
Pod documented
41 0 my $class = shift;
42 0 require Search::Tools::Transliterate;
43 0 return Search::Tools::Transliterate->new->convert(@_);
44 }
45  
46 0 ▶sub spellcheck {
Subroutine spellcheck: not called CC=1 SCAR=6.9
Pod documented
47 0 my $class = shift;
48 0 require Search::Tools::SpellCheck;
49 0 return Search::Tools::SpellCheck->new(@_);
50 }
51  
52 16 ▶sub slurp {
Subroutine slurp: called CC=7 SCAR=23.0
Pod documented
53 16 my ( $self, $file ) = @_;
54 16 my ( $buf, $fh );
55 16 my ( $name, $path, $suffix ) = fileparse( $file, qr/\.[^.]*/ );
56 16 $suffix = lc($suffix);
57 16 ▶ if ( $suffix eq '.gz' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($suffix eq '.gz') { } 0 16 16
elsif ($suffix eq '.bz2') { } 0 16 16
58 0 require IO::Uncompress::Gunzip;
59 0 $fh = IO::Uncompress::Gunzip->new($file);
60 }
61 elsif ( $suffix eq '.bz2' ) {
62 0 require IO::Uncompress::Bunzip2;
63 0 ▶ $fh = IO::Uncompress::Bunzip2->new($file)
Branch: 1 branch
BranchTrueFalseTotal
$fh = "IO::Uncompress::Bunzip2"->new($file) or die "bunzip2 failed: $IO::Uncompress::Bunzip2::Bunzip2Error\n" 0 0 0
64 or die "bunzip2 failed: $IO::Uncompress::Bunzip2::Bunzip2Error\n";
65  
66 }
67 else {
68 16 require IO::File;
69 16 ▶ $fh = openhandle($file) || IO::File->new( $file, '<' );
Condition33%1/3
&openhandle($file) || 'IO::File'->new($file, '<')
l!l&&r!l&&!r
0160
MC/DC0%0/2
&openhandle($file) || 'IO::File'->new($file, '<')
&openhandle($file) 'IO::File'->new($file, '<')
Truth table33%1/3
A || B
A= &openhandle($file)B= 'IO::File'->new($file, '<')
ABresult
1X1
011
000
70 }
71  
72 16 ▶ die "Failed to open $file: $!" unless $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless $fh 0 16 16
73  
74 16 ▶ while ( my $ln = $fh->getline ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ln = $fh->getline) 1918 16 1934
75 1918 $buf .= $ln;
76 }
77  
78 16 return $buf;
79 }
80  
81 41 1;
82  
83 __END__
« blib/lib/Search/Tools/ArgNormalizer.pm ↑ Summary blib/lib/Search/Tools/Query.pm »