blib/lib/DBIO/PostgreSQL/Extension.pm

filter: Statementstmt 100% 45 / 45 Branchbran 100% 16 / 16 Conditioncond 62.5% 5 / 8 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 15 / 15 Podpod 100% 5 / 5 totaltotal 93.5% 87 / 93 CC 14 SCAR 16.5
CC
14
Cov
96%
resolve_list
11.0
family_class
3.0
__ANON__
2.0
CRAP 5.2
« blib/lib/DBIO/PostgreSQL/ResultSet.pm ↑ Summary blib/lib/DBIO/PostgreSQL/Diff/SequenceOwner.pm »
1 package DBIO::PostgreSQL::Extension;
2 # ABSTRACT: The extension class of a PostgreSQL extension without rules, and the driver's table of the family's classes
3  
4 124 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 124 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 124 our $VERSION = '0.900007';
8  
9 124 ▶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 124 our %FAMILY = (
16 age => [ 'DBIO::PostgreSQL::Age::Extension', 'DBIO-PostgreSQL-Age' ],
17 postgis => [ 'DBIO::PostgreSQL::PostGIS::Extension', 'DBIO-PostgreSQL-PostGIS' ],
18 postgis_topology => [ 'DBIO::PostgreSQL::PostGIS::Topology::Extension', 'DBIO-PostgreSQL-PostGIS' ],
19 );
20  
21  
22 87 ▶sub extension_interface { 1 }
Subroutine extension_interface: called CC=1 SCAR=0.0
Pod documented
23  
24  
25 44 ▶sub driver { 'DBIO::PostgreSQL' }
Subroutine driver: called CC=1 SCAR=0.0
Pod documented
26  
27  
28 92 ▶sub family_class {
Subroutine family_class: called CC=3 SCAR=11.1
Pod documented
29 92 my ($class, $name) = @_;
30 92 ▶ my $entry = $FAMILY{$name // ''} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $entry = $DBIO::PostgreSQL::Extension::FAMILY{$name // ""} or return 6 86 92
Condition50%1/2
$name // ""
l!l
920
MC/DC0%0/1
$name // ""
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
31 6 return @$entry;
32 }
33  
34  
35 272 ▶sub resolve_list {
Subroutine resolve_list: called CC=11 SCAR=24.0
Pod documented
36 272 my ($class, $schema, %opt) = @_;
37 272 ▶ return undef unless $schema;
Branch: 1 branch
BranchTrueFalseTotal
unless $schema 1 271 272
38  
39 271 require DBIO::PostgreSQL::DDL;
40 271 ▶ my $schemas = DBIO::PostgreSQL::DDL::_schema_decl($schema, 'pg_extension_schemas') // {};
Condition50%1/2
DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_schemas") // {}
l!l
2710
MC/DC0%0/1
DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_schemas") // {}
DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_schemas")
Truth table50%1/2
A
A= DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_schemas")
Aresult
11
00
41 271 ▶ my $classes = DBIO::PostgreSQL::DDL::_schema_decl($schema, 'pg_extension_classes') // {};
Condition50%1/2
DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_classes") // {}
l!l
2710
MC/DC0%0/1
DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_classes") // {}
DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_classes")
Truth table50%1/2
A
A= DBIO::PostgreSQL::DDL::_schema_decl($schema, "pg_extension_classes")
Aresult
11
00
42  
43 271 my @declaration;
44 271 for my $name (DBIO::PostgreSQL::DDL::_schema_decl($schema, 'pg_extensions')) {
45 153 my %options;
46 153 ▶ $options{schema} = $schemas->{$name} if defined $schemas->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $schemas->{$name} 45 108 153
47 153 ▶ $options{class} = $classes->{$name} if defined $classes->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $classes->{$name} 66 87 153
48 153 ▶ push @declaration, $name, (%options ? \%options : ());
Branch: 1 branch
BranchTrueFalseTotal
%options ? : 102 51 153
49 }
50 271 ▶ return undef unless @declaration;
Branch: 1 branch
BranchTrueFalseTotal
unless @declaration 171 100 271
51  
52 100 require DBIO::Extension::List;
53 my $list = DBIO::Extension::List->new(
54 declaration => \@declaration,
55 87 ▶ class_table => sub { $class->family_class($_[0]) },
Subroutine __ANON__: called CC=1 SCAR=0.0
56 100 plain_class => __PACKAGE__,
57 );
58 94 ▶ $list->check_driver('DBIO::PostgreSQL') if $opt{check_driver} // 1;
Branch: 1 branch
BranchTrueFalseTotal
if $opt{"check_driver"} // 1 49 45 94
Condition100%2/2
$opt{"check_driver"} // 1
l!l
4549
MC/DC100%1/1
$opt{"check_driver"} // 1
$opt{"check_driver"}
Truth table100%2/2
A
A= $opt{"check_driver"}
Aresult
11
00
59 92 return $list;
60 }
61  
62  
63 71 ▶sub driver_helpers {
Subroutine driver_helpers: called CC=1 SCAR=0.0
Pod documented
64 71 require DBIO::PostgreSQL::Util;
65 71 require DBIO::PostgreSQL::Introspect;
66 71 ▶ my $key = sub { @_ > 1 ? DBIO::PostgreSQL::Introspect->qualified_key(@_) : $_[0] };
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 3 94 97
67 return {
68 quote_ident => \&DBIO::PostgreSQL::Util::quote_ident,
69 quote_qualified => \&DBIO::PostgreSQL::Util::quote_qualified,
70 1 ▶ qualified_key => sub { DBIO::PostgreSQL::Introspect->qualified_key(@_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
71 47 ▶ schema => sub { [ schema => $_[0] ] },
Subroutine __ANON__: called CC=1 SCAR=0.0
72 2 ▶ table => sub { [ table => $key->(@_) ] },
Subroutine __ANON__: called CC=1 SCAR=0.0
73 1 ▶ type => sub { [ type => $key->(@_) ] },
Subroutine __ANON__: called CC=1 SCAR=0.0
74 94 ▶ column => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
75 94 my $column = pop;
76 94 return [ column => $key->(@_), $column ];
77 },
78 71 };
79 }
80  
81 124 1;
82  
83 __END__
« blib/lib/DBIO/PostgreSQL/ResultSet.pm ↑ Summary blib/lib/DBIO/PostgreSQL/Diff/SequenceOwner.pm »