line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1555
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
47
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Footprintless::Plugin::Database; |
5
|
|
|
|
|
|
|
$Footprintless::Plugin::Database::VERSION = '1.01'; |
6
|
|
|
|
|
|
|
# ABSTRACT: A Footprintless plugin for working with databases |
7
|
|
|
|
|
|
|
# PODNAME: Footprintless::Plugin::Database |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Footprintless::Util qw(dynamic_module_new); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
48
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
4
|
use parent qw(Footprintless::Plugin); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub db { |
14
|
8
|
|
|
8
|
1
|
28
|
my ( $self, $footprintless, $coordinate, @rest ) = @_; |
15
|
8
|
50
|
|
|
|
40
|
die("database plugin config required") unless ( $self->{config} ); |
16
|
|
|
|
|
|
|
|
17
|
8
|
|
|
|
|
27
|
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
|
50
|
|
|
|
156
|
: undef; |
|
|
100
|
|
|
|
|
|
24
|
8
|
100
|
|
|
|
50
|
if ($provider) { |
25
|
7
|
|
|
|
|
26
|
return dynamic_module_new( $provider, $footprintless, $coordinate, @rest ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
1
|
50
|
|
|
|
4
|
if ( $entity->{provider} ) { |
29
|
1
|
|
|
|
|
25
|
die("unsupported database provider: $entity->{provider}"); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
else { |
32
|
0
|
|
|
|
|
0
|
die("provider not specified and no default configured"); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub db_command_helper { |
38
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $footprintless, $coordinate, @rest ) = @_; |
39
|
|
|
|
|
|
|
return $self->{config}{command_helper} |
40
|
|
|
|
|
|
|
? dynamic_module_new( $self->{config}{command_helper} ) |
41
|
0
|
0
|
|
|
|
0
|
: dynamic_module_new('Footprintless::Plugin::Database::DefaultCommandHelper'); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub factory_methods { |
45
|
8
|
|
|
8
|
1
|
27747
|
my ($self) = @_; |
46
|
|
|
|
|
|
|
return { |
47
|
|
|
|
|
|
|
db => sub { |
48
|
8
|
|
|
8
|
|
88
|
return $self->db(@_); |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
db_command_helper => sub { |
51
|
0
|
|
|
0
|
|
|
return $self->db_command_helper(@_); |
52
|
|
|
|
|
|
|
} |
53
|
8
|
|
|
|
|
84
|
}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |