DBSchema/_util.pm

filter: Statementstmt 80.0% 28 / 35 Branchbran 35.7% 5 / 14 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 62.6% 42 / 67 SCAR 27.0
CC
10
Cov
64%
_load_driver
8.1
_dbh
6.5
_parse_opt
6.0
CRAP 14.8
« DBSchema/DBD/Oracle.pm ↑ Summary DBSchema/DBD.pm »
1 # internal utility subroutines used by multiple classes
2  
3 package DBIx::DBSchema::_util;
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use vars qw(@ISA @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 @ISA = qw(Exporter);
12 2 @EXPORT_OK = qw( _load_driver _dbh _parse_opt );
13  
14 sub _load_driver {
15 2 ▶ my($dbh) = @_;
Subroutine _load_driver: called CC=6 SCAR=20.9
16 2 my $driver;
17 2 ▶ if ( ref($dbh) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $dbh) { } 0 2 2
18 0 $driver = $dbh->{Driver}->{Name};
19 } else {
20 2 ▶ $dbh =~ s/^dbi:(\w*?)(?:\((.*?)\))?://i #nicked from DBI->connect
Branch: 1 branch
BranchTrueFalseTotal
$dbh =~ s/^dbi:(\w*?)(?:\((.*?)\))?://i or "" =~ /()/ 0 2 2
21 or '' =~ /()/; # ensure $1 etc are empty if match fails
22 2 ▶ $driver = $1 or confess "can't parse data source: $dbh";
Branch: 1 branch
BranchTrueFalseTotal
$driver = $1 or confess("can't parse data source: $dbh") 0 2 2
23 }
24  
25 #require "DBIx/DBSchema/DBD/$driver.pm";
26 #$driver;
27 2 ▶ eval 'require "DBIx/DBSchema/DBD/$driver.pm"' and $driver or die $@;
Branch: 1 branch
BranchTrueFalseTotal
eval "require \"DBIx/DBSchema/DBD/\$driver.pm\"" and $driver or die $@ 0 2 2
Condition33%1/3
eval "require \"DBIx/DBSchema/DBD/\$driver.pm\"" and $driver
!ll&&!rl&&r
002
MC/DC0%0/2
eval "require \"DBIx/DBSchema/DBD/\$driver.pm\"" and $driver
eval "require \"DBIx/DBSchema/DBD/\$driver.pm\"" $driver
Truth table33%1/3
A and B
A= eval "require \"DBIx/DBSchema/DBD/\$driver.pm\""B= $driver
ABresult
0X0
100
111
28 }
29  
30 #sub _dbh_or_dbi_connect_args {
31 sub _dbh {
32 1 ▶ my($dbh) = shift;
Subroutine _dbh: called CC=4 SCAR=18.7
33 1 my $created_dbh = 0;
34 1 ▶ unless ( ref($dbh) || ! @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $dbh or not @_) 0 1 1
Condition33%1/3
ref $dbh or not @_
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $dbh or not @_
ref $dbh not @_
Truth table33%1/3
A or not(B)
A= ref $dbhB= not @_
ABresult
1X1
011
000
35 0 ▶ $dbh = DBI->connect( $dbh, @_ ) or die $DBI::errstr;
Branch: 1 branch
BranchTrueFalseTotal
$dbh = "DBI"->connect($dbh, @_) or die $DBI::errstr 0 0 0
36 0 $created_dbh = 1;
37 }
38  
39 1 ( $dbh, $created_dbh );
40 }
41  
42 sub _parse_opt {
43 0 ▶ my $optref = shift;
Subroutine _parse_opt: not called CC=2 SCAR=17.9
44 0 ▶ if ( ref( $optref->[0] ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $optref->[0] eq 'HASH') { } 0 0 0
45 0 shift @$optref;
46 } else {
47 0 {};
48 }
49 }
50  
51 2 1;
52  
« DBSchema/DBD/Oracle.pm ↑ Summary DBSchema/DBD.pm »