blib/lib/DBD/SQLite/BundledExtensions.pm

filter: Statementstmt 61.7% 29 / 47 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 6 / 15 Podpod 100% 9 / 9 totaltotal 62.3% 48 / 77 CC 4 SCAR 5.7
CC
4
Cov
62%
_load_extension
2.0
_locate_extension_library
2.0
__ANON__
2.0
CRAP 1.8
« blib/lib/DBD/SQLite/BundledExtensions/Install/Files.pm ↑ Summary
1 package DBD::SQLite::BundledExtensions;
2  
3 # ABSTRACT: Provides a number of C extensions for DBD::SQLite and some functions to help load them
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use File::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION="0.003";
11  
12 1 for my $ext (qw/spellfix csv ieee754 nextchar percentile series totype wholenumber eval/) {
13 0 ▶ eval "sub load_${ext} {my (\$self, \$dbh)=\@_; \$self->_load_extension(\$dbh, '${ext}')}";
Subroutine load_csv: not called CC=1 SCAR=6.2
Subroutine load_eval: not called CC=1 SCAR=6.2
Subroutine load_ieee754: not called CC=1 SCAR=6.2
Subroutine load_nextchar: not called CC=1 SCAR=6.2
Subroutine load_percentile: not called CC=1 SCAR=6.2
Subroutine load_series: not called CC=1 SCAR=6.2
Subroutine load_spellfix: not called CC=1 SCAR=6.2
Subroutine load_totype: not called CC=1 SCAR=6.2
Subroutine load_wholenumber: not called CC=1 SCAR=6.2
Pod documented
Pod documented
Pod documented
Pod documented
Pod documented
Pod documented
Pod documented
Pod documented
Pod documented
14 }
15  
16 9 ▶sub _load_extension {
Subroutine _load_extension: called CC=2 SCAR=7.0
17 9 my ($self, $dbh, $extension_name) = @_;
18  
19 9 my $file = $self->_locate_extension_library($extension_name);
20  
21 9 $dbh->sqlite_enable_load_extension(1);
22 9 ▶ $dbh->do("select load_extension(?)", {}, $file)
Branch: 1 branch
BranchTrueFalseTotal
$dbh->do("select load_extension(?)", {}, $file) or die "Cannot load '${extension_name}' extension: " . $dbh->errstr 9 0 9
23 or die "Cannot load '$extension_name' extension: " . $dbh->errstr();
24 }
25  
26 9 ▶sub _locate_extension_library {
Subroutine _locate_extension_library: called CC=2 SCAR=6.9
27 9 my ($self, $extension_name) = @_;
28 9 my $sofile;
29  
30 171 ▶ my $wanted = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
31 171 my $file = $File::Find::name;
32  
33 171 ▶ if ($file =~ m/DBD-SQLite-BundledExtensions.\Q$extension_name\E\.(so|dll|dylib)$/i){
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /DBD-SQLite-BundledExtensions.\Q$extension_name\E\.(so|dll|dylib)$/i) 9 162 171
34 9 $sofile = $file;
35 9 die; # bail out on the first one we find, this might need to be more configurable
36 }
37 9 };
38  
39 9 eval {find({wanted => $wanted, no_chdir => 1}, @INC);};
40  
41 9 ▶ if ($sofile) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sofile) 9 0 9
42 9 $sofile = File::Spec->rel2abs($sofile); # Make it an absolute path, if it isn't already. Aids in portability
43 }
44  
45 9 return $sofile;
46 }
47  
48 1 1;
49 __END__
« blib/lib/DBD/SQLite/BundledExtensions/Install/Files.pm ↑ Summary