blib/lib/DBIO/DuckDB.pm

filter: Statementstmt 100% 54 / 54 Branchbran 91.6% 22 / 24 Conditioncond 93.3% 14 / 15 MC/DCmcdc 87.5% 7 / 8 Subroutinesub 100% 9 / 9 Podpod 100% 3 / 3 totaltotal 96.4% 109 / 113 CC 19 SCAR 23.4
CC
19
Cov
97%
duckdb_extensions
16.0
_register_extension_layers
4.0
BEGIN
1.0
CRAP 10.3
« blib/lib/DBIO/DuckDB/Introspect.pm ↑ Summary blib/lib/DBIO/DuckDB/Util.pm »
1 package DBIO::DuckDB;
2 3 our $VERSION = '0.900007';
3  
4  
5 # ABSTRACT: DuckDB-specific schema management for DBIO
6  
7 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use base 'DBIO::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use DBIO::DuckDB::Extension ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 __PACKAGE__->mk_classdata('_duckdb_extensions' => []);
16 3 __PACKAGE__->mk_classdata('_duckdb_extension_classes' => {});
17  
18  
19 2 ▶sub connection {
Subroutine connection: called CC=1 SCAR=0.0
Pod documented
20 2 my ($self, @info) = @_;
21 2 $self->storage_type('+DBIO::DuckDB::Storage');
22 2 $self->_register_extension_layers;
23 2 return $self->next::method(@info);
24 }
25  
26 # The classes are loaded and checked for their interface here, since the layer
27 # has to be chosen before the storage is built; their driver assertion waits
28 # for the first use of the connection.
29 2 ▶sub _register_extension_layers {
Subroutine _register_extension_layers: called CC=4 SCAR=13.9
30 2 my ($self) = @_;
31 2 ▶ my $list = DBIO::DuckDB::Extension->resolve_list($self, check_driver => 0)
Branch: 1 branch
BranchTrueFalseTotal
my $list = "DBIO::DuckDB::Extension"->resolve_list($self, "check_driver", 0) or return 1 1 2
32 or return;
33 1 for my $entry ($list->entries) {
34 1 my $layer = $entry->{class}->storage_layer;
35 1 ▶ $self->register_storage_layer($layer) if defined $layer;
Branch: 1 branch
BranchTrueFalseTotal
if defined $layer 1 0 1
36 }
37 1 return;
38 }
39  
40  
41 30 ▶sub duckdb_extensions {
Subroutine duckdb_extensions: called CC=16 SCAR=27.7
Pod documented
42 30 my $class = shift;
43 30 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 17 13 30
44 17 my (@names, %classes);
45 17 my @args = @_;
46 17 ▶ while (@args) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 22 9 31
47 22 my $name = shift @args;
48 22 ▶ Carp::croak(sprintf
Branch: 3 branches
BranchTrueFalseTotal
if not defined $name or ref $name or not length $name 4 18 22
defined $name ? : 3 1 4
ref $name ? : 2 1 3
Condition100%6/6
not defined $name or ref $name or not length $name
l!l&&r!l&&!r
3118
not defined $name or ref $name
l!l&&r!l&&!r
1219
MC/DC100%3/3
not defined $name or ref $name or not length $name
not defined $name ref $name not length $name
Truth table100%4/4
not(A) or B or not(C)
A= not defined $nameB= ref $nameC= not length $name
ABCresult
1XX1
01X1
0011
0000
49 'duckdb_extensions(): an extension name is expected, got %s',
50 defined $name ? (ref $name ? 'a ' . ref($name) . ' reference' : "'$name'") : 'undef')
51 if !defined $name || ref $name || !length $name;
52 18 push @names, $name;
53 18 ▶ next unless @args && ref $args[0];
Branch: 1 branch
BranchTrueFalseTotal
unless @args and ref $args[0] 6 12 18
Condition100%3/3
@args and ref $args[0]
!ll&&!rl&&r
4212
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
54 12 my $opts = shift @args;
55 12 ▶ Carp::croak("duckdb_extensions(): the options of extension '$name' are a hashref")
Branch: 1 branch
BranchTrueFalseTotal
unless ref $opts eq "HASH" 0 12 12
56 unless ref $opts eq 'HASH';
57 12 my @unknown = grep { $_ ne 'class' } sort keys %$opts;
58 Carp::croak(sprintf
59 "duckdb_extensions(): extension '%s' has no option %s; the only option is 'class'",
60 12 ▶ $name, join(', ', map { "'$_'" } @unknown))
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 1 11 12
61 if @unknown;
62 11 ▶ Carp::croak("duckdb_extensions(): extension '$name' has an empty options hashref; give 'class'")
Branch: 1 branch
BranchTrueFalseTotal
unless keys %$opts 1 10 11
63 unless keys %$opts;
64 10 my $extension_class = $opts->{class};
65 10 ▶ Carp::croak("duckdb_extensions(): extension '$name' needs a 'class', a class name")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $extension_class and not ref $extension_class and $extension_class =~ /\A[A-Za-z_]\w*(?:::\w+)*\z/ 2 8 10
Condition83%5/6
defined $extension_class and not ref $extension_class and $extension_class =~ /\A[A-Za-z_]\w*(?:::\w+)*\z/
!ll&&!rl&&r
118
defined $extension_class and not ref $extension_class
!ll&&!rl&&r
109
MC/DC66%2/3
defined $extension_class and not ref $extension_class and $extension_class =~ /\A[A-Za-z_]\w*(?:::\w+)*\z/
defined $extension_class not ref $extension_class $extension_class =~ /\A[A-Za-z_]\w*(?:::\w+)*\z/
Truth table75%3/4
A and not(B) and C
A= defined $extension_classB= not ref $extension_classC= $extension_class =~ /\A[A-Za-z_]\w*(?:::\w+)*\z/
ABCresult
0XX0
10X0
1100
1111
66 unless defined $extension_class && !ref $extension_class
67 && $extension_class =~ /\A[A-Za-z_]\w*(?:::\w+)*\z/;
68 8 $classes{$name} = $extension_class;
69 }
70 9 $class->_duckdb_extensions(\@names);
71 9 $class->_duckdb_extension_classes(\%classes);
72 }
73 22 return @{ $class->_duckdb_extensions };
74 }
75  
76  
77 14 ▶sub duckdb_extension_classes { return { %{ $_[0]->_duckdb_extension_classes } } }
Subroutine duckdb_extension_classes: called CC=1 SCAR=0.0
Pod documented
78  
79 3 1;
80  
81 __END__
« blib/lib/DBIO/DuckDB/Introspect.pm ↑ Summary blib/lib/DBIO/DuckDB/Util.pm »