Database.pm

filter: Statementstmt 86.2% 25 / 29 Branchbran 58.3% 7 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 77.7% 7 / 9 Podpod 100% 3 / 3 totaltotal 79.2% 42 / 53 CC 7 SCAR 13.5
CC
7
Cov
78%
db
6.3
db_command_helper
6.0
__ANON__
2.0
CRAP 3.9
« Database/Command/db/client.pm ↑ Summary Database/DefaultCommandHelper.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package Footprintless::Plugin::Database;
5 1 $Footprintless::Plugin::Database::VERSION = '1.06';
6 # ABSTRACT: A Footprintless plugin for working with databases
7 # PODNAME: Footprintless::Plugin::Database
8  
9 1 ▶use Footprintless::Util qw(dynamic_module_new);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use parent qw(Footprintless::Plugin);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 8 ▶sub db {
Subroutine db: called CC=6 SCAR=18.5
Pod documented
14 8 my ( $self, $footprintless, $coordinate, @rest ) = @_;
15 8 ▶ die("database plugin config required") unless ( $self->{config} );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"config"} 0 8 8
16  
17 8 my $entity = $footprintless->entities()->get_entity($coordinate);
18  
19 my $provider =
20 $entity->{provider} ? $self->{config}{providers}{ $entity->{provider} }
21 : $self->{config}{default_provider}
22 ? $self->{config}{providers}{ $self->{config}{default_provider} }
23 8 ▶ : undef;
Branch: 2 branches
BranchTrueFalseTotal
$entity->{'provider'} ? : 2 6 8
$self->{'config'}{'default_provider'} ? : 6 0 6
24 8 ▶ if ($provider) {
Branch: 1 branch
BranchTrueFalseTotal
if ($provider) { } 7 1 8
25 7 return dynamic_module_new( $provider, $footprintless, $coordinate, @rest );
26 }
27 else {
28 1 ▶ if ( $entity->{provider} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entity->{'provider'}) { } 1 0 1
29 1 die("unsupported database provider: $entity->{provider}");
30 }
31 else {
32 0 die("provider not specified and no default configured");
33 }
34 }
35 }
36  
37 0 ▶sub db_command_helper {
Subroutine db_command_helper: not called CC=2 SCAR=17.9
Pod documented
38 0 my ( $self, $footprintless, $coordinate, @rest ) = @_;
39 return $self->{config}{command_helper}
40 ? dynamic_module_new( $self->{config}{command_helper} )
41 0 ▶ : dynamic_module_new('Footprintless::Plugin::Database::DefaultCommandHelper');
Branch: 1 branch
BranchTrueFalseTotal
$self->{'config'}{'command_helper'} ? : 0 0 0
42 }
43  
44 8 ▶sub factory_methods {
Subroutine factory_methods: called CC=1 SCAR=0.2
Pod documented
45 8 my ($self) = @_;
46 return {
47 8 ▶ db => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
48 8 return $self->db(@_);
49 },
50 0 ▶ db_command_helper => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
51 0 return $self->db_command_helper(@_);
52 }
53 8 };
54 }
55  
56 1 1;
57  
58 __END__
« Database/Command/db/client.pm ↑ Summary Database/DefaultCommandHelper.pm »