| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Anego::Config; |
|
2
|
1
|
|
|
1
|
|
112480
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
25
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
26
|
|
|
4
|
1
|
|
|
1
|
|
392
|
use utf8; |
|
|
1
|
|
|
|
|
21
|
|
|
|
1
|
|
|
|
|
8
|
|
|
5
|
1
|
|
|
1
|
|
34
|
use File::Spec; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
16
|
|
|
6
|
1
|
|
|
1
|
|
3
|
use DBI; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
37
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
208
|
use Anego::Logger; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
577
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $CONFIG_PATH; |
|
11
|
|
|
|
|
|
|
our $CONFIG; |
|
12
|
|
|
|
|
|
|
|
|
13
|
0
|
0
|
|
0
|
0
|
|
sub config_path { $CONFIG_PATH || './.anego.pl' } |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub load { |
|
16
|
0
|
|
|
0
|
0
|
|
my ($class) = @_; |
|
17
|
|
|
|
|
|
|
|
|
18
|
0
|
0
|
|
|
|
|
return $CONFIG if $CONFIG; |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $config_path = $class->config_path; |
|
21
|
0
|
0
|
|
|
|
|
errorf("Could not find config file: $config_path\n") unless -f $config_path; |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
my $config = do $config_path or errorf("Could not load config file: $@"); |
|
24
|
0
|
|
|
|
|
|
$CONFIG = bless $config, $class; |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
return $CONFIG; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
|
|
0
|
0
|
|
sub schema_class { $_[0]->{schema_class} } |
|
30
|
0
|
|
|
0
|
0
|
|
sub connect_info { $_[0]->{connect_info} } |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub database { |
|
33
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
34
|
0
|
0
|
|
|
|
|
unless ($self->{database}) { |
|
35
|
0
|
|
|
|
|
|
$self->{database} = do { my (undef, $d) = $self->connect_info->[0] =~ /(database|dbname|name|db)=([\w:]+)/; $d }; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
|
37
|
0
|
|
|
|
|
|
return $self->{database}; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub schema_path { |
|
41
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
42
|
0
|
0
|
|
|
|
|
unless ($self->{schema_path}) { |
|
43
|
0
|
|
|
|
|
|
my @splited_schema_class = split /::/, $self->schema_class; |
|
44
|
0
|
|
|
|
|
|
my $basename = pop @splited_schema_class; |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$self->{schema_path} = File::Spec->catfile('lib', @splited_schema_class, "$basename.pm"); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
0
|
|
|
|
|
|
return $self->{schema_path}; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub rdbms { |
|
52
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
53
|
0
|
0
|
|
|
|
|
unless ($self->{rdbms}) { |
|
54
|
0
|
|
|
|
|
|
my $dsn = $self->connect_info->[0]; |
|
55
|
|
|
|
|
|
|
$self->{rdbms} = $dsn =~ /:mysql:/ ? 'MySQL' |
|
56
|
|
|
|
|
|
|
: $dsn =~ /:Pg:/ ? 'PostgreSQL' |
|
57
|
0
|
0
|
|
|
|
|
: do { my ($d) = $dsn =~ /dbi:(.*?):/; $d }; |
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} |
|
59
|
0
|
|
|
|
|
|
return $self->{rdbms}; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub dbh { |
|
63
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
64
|
0
|
0
|
|
|
|
|
unless ($self->{dbh}) { |
|
65
|
0
|
|
|
|
|
|
$self->{dbh} = DBI->connect(@{ $self->connect_info }); |
|
|
0
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
|
67
|
0
|
|
|
|
|
|
return $self->{dbh}; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |