blib/lib/DBIO/SQLite/Extension.pm

filter: Statementstmt 97.5% 40 / 41 Branchbran 100% 14 / 14 Conditioncond 69.2% 9 / 13 MC/DCmcdc 42.8% 3 / 7 Subroutinesub 92.3% 12 / 13 Podpod 100% 6 / 6 totaltotal 89.3% 84 / 94 CC 15 SCAR 15.0
CC
15
Cov
93%
resolve_list
9.0
activation
4.1
family_class
3.0
CRAP 4.5
« blib/lib/DBIO/SQLite/Util.pm ↑ Summary blib/lib/DBIO/SQLite/Adapter.pm »
1 package DBIO::SQLite::Extension;
2 # ABSTRACT: The extension class of a SQLite extension without rules, and the driver's table of the family's classes
3  
4 209 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 209 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 209 our $VERSION = '0.900007';
8  
9 209 ▶use base 'DBIO::Extension';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # The driver's fixed table of the extensions the family ships a class for
12 # (ADR 0066 section 1.2): the engine's name to [ class, distribution ]. The
13 # table maps names to existing classes, nothing is derived from a name. A
14 # declaration that names a class of its own wins over it.
15 209 our %FAMILY = (
16 fts5 => [ 'DBIO::SQLite::Extension::FTS5', 'DBIO-SQLite' ],
17 rtree => [ 'DBIO::SQLite::Extension::RTree', 'DBIO-SQLite' ],
18 );
19  
20  
21 83 ▶sub extension_interface { 1 }
Subroutine extension_interface: called CC=1 SCAR=0.0
Pod documented
22  
23  
24 46 ▶sub driver { 'DBIO::SQLite' }
Subroutine driver: called CC=1 SCAR=0.0
Pod documented
25  
26  
27 67 ▶sub activation {
Subroutine activation: called CC=4 SCAR=14.1
Pod documented
28 67 my ($class, $ctx) = @_;
29 67 ▶ my $self = $ctx->{self} || {};
Condition50%1/2
$ctx->{'self'} || {}
l!l
670
MC/DC0%0/1
$ctx->{'self'} || {}
$ctx->{'self'}
Truth table50%1/2
A
A= $ctx->{'self'}
Aresult
11
00
30 67 ▶ my $library = ($self->{options} || {})->{library};
Condition50%1/2
$self->{'options'} || {}
l!l
670
MC/DC0%0/1
$self->{'options'} || {}
$self->{'options'}
Truth table50%1/2
A
A= $self->{'options'}
Aresult
11
00
31 67 ▶ return undef unless defined $library;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $library 53 14 67
32 14 return { load => { $self->{name} => $library } };
33 }
34  
35  
36 73 ▶sub family_class {
Subroutine family_class: called CC=3 SCAR=11.1
Pod documented
37 73 my ($class, $name) = @_;
38 73 ▶ my $entry = $FAMILY{$name // ''} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $entry = $DBIO::SQLite::Extension::FAMILY{$name // ""} or return 44 29 73
Condition50%1/2
$name // ""
l!l
730
MC/DC0%0/1
$name // ""
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
39 44 return @$entry;
40 }
41  
42  
43 1704 ▶sub resolve_list {
Subroutine resolve_list: called CC=9 SCAR=22.0
Pod documented
44 1704 my ($class, $schema, %opt) = @_;
45 1704 ▶ return undef unless $schema;
Branch: 1 branch
BranchTrueFalseTotal
unless $schema 1 1703 1704
46  
47 1703 ▶ my $options = _schema_decl($schema, 'sqlite_extension_options') // {};
Condition100%2/2
_schema_decl($schema, "sqlite_extension_options") // {}
l!l
898805
MC/DC100%1/1
_schema_decl($schema, "sqlite_extension_options") // {}
_schema_decl($schema, "sqlite_extension_options")
Truth table100%2/2
A
A= _schema_decl($schema, "sqlite_extension_options")
Aresult
11
00
48  
49 1703 my @declaration;
50 1703 for my $name (_schema_decl($schema, 'sqlite_extensions')) {
51 92 my $own = $options->{$name};
52 92 ▶ push @declaration, $name, ($own && %$own ? { %$own } : ());
Branch: 1 branch
BranchTrueFalseTotal
$own && %$own ? : 47 45 92
Condition66%2/3
$own and %$own
!ll&&!rl&&r
45047
MC/DC50%1/2
$own and %$own
$own %$own
Truth table66%2/3
A and B
A= $ownB= %$own
ABresult
0X0
100
111
53 }
54 1703 ▶ return undef unless @declaration;
Branch: 1 branch
BranchTrueFalseTotal
unless @declaration 1644 59 1703
55  
56 59 require DBIO::Extension::List;
57 my $list = DBIO::Extension::List->new(
58 declaration => \@declaration,
59 67 ▶ class_table => sub { $class->family_class($_[0]) },
Subroutine __ANON__: called CC=1 SCAR=0.0
60 59 plain_class => __PACKAGE__,
61 );
62 55 ▶ $list->check_driver('DBIO::SQLite') if $opt{check_driver} // 1;
Branch: 1 branch
BranchTrueFalseTotal
if $opt{"check_driver"} // 1 33 22 55
Condition100%2/2
$opt{"check_driver"} // 1
l!l
2233
MC/DC100%1/1
$opt{"check_driver"} // 1
$opt{"check_driver"}
Truth table100%2/2
A
A= $opt{"check_driver"}
Aresult
11
00
63 53 return $list;
64 }
65  
66 # A schema class that does not load the DBIO::SQLite component declares none.
67 3406 ▶sub _schema_decl {
Subroutine _schema_decl: called CC=2 SCAR=6.9
68 3406 my ($schema, $method) = @_;
69 3406 ▶ return $schema->can($method) ? $schema->$method : ();
Branch: 1 branch
BranchTrueFalseTotal
$schema->can($method) ? : 1796 1610 3406
70 }
71  
72  
73 53 ▶sub driver_helpers {
Subroutine driver_helpers: called CC=1 SCAR=0.2
Pod documented
74 53 require DBIO::SQLite::Util;
75 return {
76 quote_ident => \&DBIO::SQLite::Util::quote_identifier,
77 432 ▶ table => sub { [ table => $_[0] ] },
Subroutine __ANON__: called CC=1 SCAR=0.0
78 0 ▶ column => sub { [ column => $_[0], $_[1] ] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
79 53 };
80 }
81  
82 209 1;
83  
84 __END__
« blib/lib/DBIO/SQLite/Util.pm ↑ Summary blib/lib/DBIO/SQLite/Adapter.pm »