blib/lib/DBIO/SQLite.pm

filter: Statementstmt 100% 57 / 57 Branchbran 89.2% 25 / 28 Conditioncond 90.6% 29 / 32 MC/DCmcdc 81.2% 13 / 16 Subroutinesub 100% 9 / 9 Podpod 100% 3 / 3 totaltotal 93.7% 136 / 145 CC 28 SCAR 29.0
CC
28
Cov
95%
sqlite_extensions
25.3
_register_extension_layers
4.0
BEGIN
1.0
CRAP 18.2
« blib/lib/DBIO/SQLite/Diff/Column.pm ↑ Summary blib/lib/DBIO/SQLite/SQLMaker.pm »
1 package DBIO::SQLite;
2 # ABSTRACT: SQLite-specific schema management for DBIO
3 42 our $VERSION = '0.900007';
4 42 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 42 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 42 ▶use base 'DBIO::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 42 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 42 ▶use DBIO::SQLite::Extension ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 42 __PACKAGE__->mk_classdata('_sqlite_extensions' => []);
13 42 __PACKAGE__->mk_classdata('_sqlite_extension_options' => {});
14  
15  
16 946 ▶sub sqlite_extensions {
Subroutine sqlite_extensions: called CC=25 SCAR=32.3
Pod documented
17 946 my $class = shift;
18 946 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 43 903 946
19 43 my (@names, %options);
20 43 my @args = @_;
21 43 ▶ while (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 65 32 97
22 65 my $name = shift @args;
23 65 ▶ Carp::croak(sprintf 'sqlite_extensions(): an extension name is expected, got %s',
Branch: 3 branches
BranchTrueFalseTotal
if not defined $name or ref $name or not length $name 3 62 65
ref $name ? : 2 1 3
defined $name ? : 0 1 1
Condition83%5/6
not defined $name or ref $name or not length $name
l!l&&r!l&&!r
3062
not defined $name or ref $name
l!l&&r!l&&!r
1262
MC/DC66%2/3
not defined $name or ref $name or not length $name
not defined $name ref $name not length $name
Truth table75%3/4
not(A) or B or not(C)
A= not defined $nameB= ref $nameC= not length $name
ABCresult
1XX1
01X1
0011
0000
24 ref $name ? 'a ' . ref($name) . ' reference' : defined $name ? "'$name'" : 'undef')
25 if !defined $name || ref $name || !length $name;
26 62 ▶ push @names, $name unless grep { $_ eq $name } @names;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $name;} @names 62 0 62
27 62 ▶ next unless @args && ref $args[0];
Branch: 1 branch
BranchTrueFalseTotal
unless @args and ref $args[0] 25 37 62
Condition100%3/3
@args and ref $args[0]
!ll&&!rl&&r
131237
MC/DC100%2/2
@args and ref $args[0]
@args ref $args[0]
Truth table100%3/3
A and B
A= @argsB= ref $args[0]
ABresult
0X0
100
111
28  
29 37 my $opts = shift @args;
30 37 ▶ Carp::croak("sqlite_extensions(): the options of extension '$name' are a hashref")
Branch: 1 branch
BranchTrueFalseTotal
unless ref $opts eq "HASH" 0 37 37
31 unless ref $opts eq 'HASH';
32 37 ▶ Carp::croak("sqlite_extensions(): extension '$name' has an empty options hashref; give 'library' or 'class'")
Branch: 1 branch
BranchTrueFalseTotal
unless %$opts 1 36 37
33 unless %$opts;
34 36 for my $key (sort keys %$opts) {
35 38 ▶ Carp::croak(sprintf
Branch: 1 branch
BranchTrueFalseTotal
unless $key eq "library" or $key eq "class" 1 37 38
Condition100%3/3
$key eq "library" or $key eq "class"
l!l&&r!l&&!r
19181
MC/DC100%2/2
$key eq "library" or $key eq "class"
$key eq "library" $key eq "class"
Truth table100%3/3
A or B
A= $key eq "library"B= $key eq "class"
ABresult
1X1
011
000
36 "sqlite_extensions(): extension '%s' has no option %s; the options are 'library' and 'class'",
37 $name, $key)
38 unless $key eq 'library' || $key eq 'class';
39 }
40 Carp::croak("sqlite_extensions(): extension '$name' needs a 'library', a plain non-empty string")
41 if exists $opts->{library}
42 35 ▶ && !(defined $opts->{library} && !ref $opts->{library} && length $opts->{library});
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts->{"library"} and not defined $opts->{"library"} && !ref($opts->{"library"}) && length $opts->{"library"} 3 32 35
Condition100%9/9
exists $opts->{"library"} and not defined $opts->{"library"} && !ref($opts->{"library"}) && length $opts->{"library"}
!ll&&!rl&&r
16163
defined $opts->{'library'} && !ref($opts->{'library'}) && length $opts->{'library'}
!ll&&!rl&&r
2116
defined $opts->{"library"} and not ref $opts->{"library"}
!ll&&!rl&&r
1117
MC/DC100%4/4
exists $opts->{"library"} and not defined $opts->{"library"} && !ref($opts->{"library"}) && length $opts->{"library"}
exists $opts->{"library"} defined $opts->{"library"} not ref $opts->{"library"} length $opts->{'library'}
Truth table100%5/5
A and not(B and not(C) && D)
A= exists $opts->{"library"}B= defined $opts->{"library"}C= not ref $opts->{"library"}D= length $opts->{'library'}
ABCDresult
0XXX0
11110
10XX1
110X1
11101
43 Carp::croak("sqlite_extensions(): extension '$name' needs a 'class', a class name")
44 if exists $opts->{class}
45 && !(defined $opts->{class} && !ref $opts->{class}
46 32 ▶ && $opts->{class} =~ /\A[A-Za-z_]\w*(?:::\w+)*\z/);
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts->{"class"} and not defined $opts->{"class"} && !ref($opts->{"class"}) && $opts->{"class"} =~ /\A[A-Za-z_]\w*(?:::\w+)*\z/ 3 29 32
Condition88%8/9
exists $opts->{"class"} and not defined $opts->{"class"} && !ref($opts->{"class"}) && $opts->{"class"} =~ /\A[A-Za-z_]\w*(?:::\w+)*\z/
!ll&&!rl&&r
14153
defined $opts->{'class'} && !ref($opts->{'class'}) && $opts->{'class'} =~ /\A[A-Za-z_]\w*(?:::\w+)*\z/
!ll&&!rl&&r
1215
defined $opts->{"class"} and not ref $opts->{"class"}
!ll&&!rl&&r
0117
MC/DC75%3/4
exists $opts->{"class"} and not defined $opts->{"class"} && !ref($opts->{"class"}) && $opts->{"class"} =~ /\A[A-Za-z_]\w*(?:::\w+)*\z/
exists $opts->{"class"} defined $opts->{"class"} not ref $opts->{"class"} $opts->{'class'} =~ /\A[A-Za-z_]\w*(?:::\w+)*\z/
Truth table80%4/5
A and not(B and not(C) && D)
A= exists $opts->{"class"}B= defined $opts->{"class"}C= not ref $opts->{"class"}D= $opts->{'class'} =~ /\A[A-Za-z_]\w*(?:::\w+)*\z/
ABCDresult
0XXX0
11110
10XX1
110X1
11101
47 29 ▶ $options{$name} = { %{ $options{$name} || {} }, %$opts };
Condition50%1/2
$options{$name} || {}
l!l
029
MC/DC0%0/1
$options{$name} || {}
$options{$name}
Truth table50%1/2
A
A= $options{$name}
Aresult
11
00
48 }
49 32 $class->_sqlite_extensions(\@names);
50 32 $class->_sqlite_extension_options(\%options);
51 }
52 935 return @{ $class->_sqlite_extensions };
53 }
54  
55  
56 904 ▶sub sqlite_extension_options {
Subroutine sqlite_extension_options: called CC=1 SCAR=0.0
Pod documented
57 904 my $class = shift;
58 904 my $own = $class->_sqlite_extension_options;
59 904 return { map { $_ => { %{ $own->{$_} } } } keys %$own };
60 }
61  
62  
63 300 ▶sub connection {
Subroutine connection: called CC=1 SCAR=0.0
Pod documented
64 300 my ($self, @info) = @_;
65 300 $self->storage_type('+DBIO::SQLite::Storage');
66 300 $self->_register_extension_layers;
67 300 return $self->next::method(@info);
68 }
69  
70 # The storage layer (ADR 0032) of every declared extension whose class names
71 # one is registered with core's register_storage_layer. An extension chooses
72 # a layer, never the driver: the driver is the one this component pinned above.
73 300 ▶sub _register_extension_layers {
Subroutine _register_extension_layers: called CC=4 SCAR=13.9
74 300 my ($self) = @_;
75 300 ▶ my $list = DBIO::SQLite::Extension->resolve_list($self, check_driver => 0)
Branch: 1 branch
BranchTrueFalseTotal
my $list = "DBIO::SQLite::Extension"->resolve_list($self, "check_driver", 0) or return 22 278 300
76 or return;
77 22 for my $entry ($list->entries) {
78 36 my $layer = $entry->{class}->storage_layer;
79 36 ▶ $self->register_storage_layer($layer) if defined $layer;
Branch: 1 branch
BranchTrueFalseTotal
if defined $layer 1 35 36
80 }
81 22 return;
82 }
83  
84 42 1;
85  
86 __END__
« blib/lib/DBIO/SQLite/Diff/Column.pm ↑ Summary blib/lib/DBIO/SQLite/SQLMaker.pm »