blib/lib/Search/Tools.pm

filter: Statementstmt 67.3% 35 / 52 Branchbran 50.0% 5 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 71.4% 10 / 14 Podpod n/a totaltotal 62.9% 51 / 81 SCAR 22.5
CC
7
Cov
63%
slurp
10.0
regexp
2.0
hiliter
2.0
CRAP 9.5
« blib/lib/Search/Tools/ArgNormalizer.pm ↑ Summary blib/lib/Search/Tools/Object.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 our $VERSION = '1.004';
10  
11 41 ▶use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 XSLoader::load( 'Search::Tools', $VERSION );
13  
14 our $XS_DEBUG = 0;
15  
16 sub parser {
17 7 ▶ my $class = shift;
Subroutine parser: called CC=1 SCAR=0.4
18 7 require Search::Tools::QueryParser;
19 0 return Search::Tools::QueryParser->new(@_);
20 }
21  
22 sub regexp {
23 0 ▶ my $class = shift;
Subroutine regexp: not called CC=1 SCAR=6.9
24  
25 0 croak("as of version 0.24 you should use parser() instead of regexp()");
26 }
27  
28 sub hiliter {
29 0 ▶ my $class = shift;
Subroutine hiliter: not called CC=1 SCAR=6.9
30 0 require Search::Tools::HiLiter;
31 0 return Search::Tools::HiLiter->new(@_);
32 }
33  
34 sub snipper {
35 1 ▶ my $class = shift;
Subroutine snipper: called CC=1 SCAR=0.4
36 1 require Search::Tools::Snipper;
37 0 return Search::Tools::Snipper->new(@_);
38 }
39  
40 sub transliterate {
41 0 ▶ my $class = shift;
Subroutine transliterate: not called CC=1 SCAR=6.9
42 0 require Search::Tools::Transliterate;
43 0 return Search::Tools::Transliterate->new->convert(@_);
44 }
45  
46 sub spellcheck {
47 0 ▶ my $class = shift;
Subroutine spellcheck: not called CC=1 SCAR=6.9
48 0 require Search::Tools::SpellCheck;
49 0 return Search::Tools::SpellCheck->new(@_);
50 }
51  
52 sub slurp {
53 3 ▶ my ( $self, $file ) = @_;
Subroutine slurp: called CC=7 SCAR=23.0
54 3 my ( $buf, $fh );
55 3 my ( $name, $path, $suffix ) = fileparse( $file, qr/\.[^.]*/ );
56 3 $suffix = lc($suffix);
57 3 ▶ if ( $suffix eq '.gz' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($suffix eq '.gz') { } 0 3 3
elsif ($suffix eq '.bz2') { } 0 3 3
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 3 require IO::File;
69 3 ▶ $fh = openhandle($file) || IO::File->new( $file, '<' );
Condition33%1/3
&openhandle($file) || 'IO::File'->new($file, '<')
l!l&&r!l&&!r
030
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 3 ▶ die "Failed to open $file: $!" unless $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless $fh 0 3 3
73  
74 3 ▶ while ( my $ln = $fh->getline ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ln = $fh->getline) 65 3 68
75 65 $buf .= $ln;
76 }
77  
78 3 return $buf;
79 }
80  
81 1;
82  
83 __END__
« blib/lib/Search/Tools/ArgNormalizer.pm ↑ Summary blib/lib/Search/Tools/Object.pm »