Chado/DBManager/Sqlite.pm

filter: Statementstmt 83.0% 49 / 59 Branchbran 40.0% 4 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 12 / 15 Podpod 0.0% 0 / 5 totaltotal 73.0% 65 / 89 CC 7 SCAR 8.5
CC
7
Cov
77%
deploy_by_client
6.0
get_client_to_deploy
3.6
_build_database
3.1
CRAP 2.3
« Chado/Role/Helper/WithBcs.pm ↑ Summary Chado/DBManager/Testpg.pm »
1 package Test::Chado::DBManager::Sqlite;
2 {
3 8 $Test::Chado::DBManager::Sqlite::VERSION = 'v4.1.1';
4 }
5  
6 8 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use MooX::late;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 8 ▶use File::Temp qw/:POSIX/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 ▶use IPC::Cmd qw/can_run run/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 8 has 'is_dynamic_schema' => (is => 'ro', isa => 'Bool', default => 1);
15 8 with 'Test::Chado::Role::HasDBManager';
16  
17 has '+dsn' => (
18 lazy => 1,
19 11 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
20 11 my $self = shift;
21 11 my $file = tmpnam();
22 11 $self->driver('SQLite');
23 11 return "dbi:SQLite:dbname=$file";
24 }
25 8 );
26  
27 11 ▶sub _build_dbh {
Subroutine _build_dbh: called CC=1 SCAR=0.0
28 11 my ($self) = @_;
29 11 return DBI->connect( $self->dsn, '', '', $self->dbi_attributes );
30 }
31  
32 1 ▶sub _build_database {
Subroutine _build_database: called CC=3 SCAR=11.4
33 1 my ($self) = @_;
34 1 my $driver_dsn;
35 1 ▶ if ( $self->driver_dsn ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->driver_dsn) { } 0 1 1
36 0 $driver_dsn = $self->driver_dsn;
37 }
38 else {
39 1 my @parsed_dsn = DBI->parse_dsn($self->dsn);
40 1 $driver_dsn = $parsed_dsn[-1];
41 }
42  
43 1 ▶ if ( $driver_dsn =~ /(dbname|(.+)?)=(\S+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($driver_dsn =~ /(dbname|(.+)?)=(\S+)/) 1 0 1
44 1 return $3;
45 }
46 }
47  
48 0 ▶sub _build_driver { return 'SQLite'}
Subroutine _build_driver: not called CC=1 SCAR=6.9
49  
50 0 ▶sub create_database {
Subroutine create_database: not called CC=1 SCAR=6.9
Pod undocumented
51 0 return 1;
52 }
53  
54 2 ▶sub drop_database {
Subroutine drop_database: called CC=1 SCAR=0.0
Pod undocumented
55 2 my ($self) = @_;
56 2 return $self->dbh->disconnect;
57 }
58  
59 1 ▶sub drop_schema {
Subroutine drop_schema: called CC=2 SCAR=6.9
Pod undocumented
60 1 my ($self) = @_;
61 1 my $dbh = $self->dbh;
62  
63 1 my $arr = $dbh->selectall_arrayref(
64 qq{SELECT name FROM sqlite_master where type = 'table' });
65 1 for my $row (@$arr) {
66 174 my $table = $row->[0];
67 174 $dbh->do(qq{ DROP TABLE $table });
68 }
69 }
70  
71 9 ▶sub get_client_to_deploy {
Subroutine get_client_to_deploy: called CC=3 SCAR=12.7
Pod undocumented
72 9 my ($self) = @_;
73 9 my $cmd;
74 9 ▶ if ( $cmd = can_run 'sqlite3' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cmd = can_run('sqlite3')) { } 0 9 9
elsif ($cmd = can_run('sqlite')) { } 0 9 9
75 0 return $cmd;
76 }
77 elsif ( $cmd = can_run 'sqlite' ) {
78 0 return $cmd;
79 }
80 else {
81 9 return $cmd;
82 }
83 }
84  
85 0 ▶sub deploy_by_client {
Subroutine deploy_by_client: not called CC=2 SCAR=17.9
Pod undocumented
86 0 my ( $self, $client ) = @_;
87 0 my $cmd = [ $client, '-noheader', $self->database, '<', $self->ddl ];
88 0 my ( $success, $error_code, $full_buf,, $stdout_buf, $stderr_buf )
89 = run( command => $cmd, verbose => 1 );
90 0 ▶ return $success if $success;
Branch: 1 branch
BranchTrueFalseTotal
if $success 0 0 0
91 0 die "unable to run command : ", $error_code, " ", $stderr_buf;
92 }
93  
94  
95 8 1;
96  
97 __END__
« Chado/Role/Helper/WithBcs.pm ↑ Summary Chado/DBManager/Testpg.pm »