line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cot::Config; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1944
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
44
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
5
|
1
|
|
|
1
|
|
27
|
use 5.008005; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
63
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.11"; |
7
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
8
|
1
|
|
|
1
|
|
932
|
use YAML (); |
|
1
|
|
|
|
|
8706
|
|
|
1
|
|
|
|
|
27
|
|
9
|
1
|
|
|
1
|
|
9
|
use File::Spec; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
28
|
|
10
|
1
|
|
|
1
|
|
6
|
use constant CONFIG_FILENAME => 'config.yaml'; |
|
1
|
|
|
|
|
33
|
|
|
1
|
|
|
|
|
54
|
|
11
|
1
|
|
|
1
|
|
6
|
use vars qw(%CONFIG); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
226
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _root { |
14
|
3
|
50
|
|
3
|
|
61
|
$ENV{COT_ROOT} || '.'; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub loadconfig { |
18
|
1
|
|
|
1
|
0
|
1
|
my $class = shift; |
19
|
1
|
50
|
|
|
|
11
|
return if $CONFIG{ $class->_root }; |
20
|
1
|
|
|
|
|
4
|
my $configpath = File::Spec->catfile( $class->_root, CONFIG_FILENAME ); |
21
|
1
|
50
|
|
|
|
41
|
return unless ( -f $configpath ); |
22
|
0
|
|
|
|
|
0
|
my $c = YAML::LoadFile($configpath); |
23
|
0
|
|
|
|
|
0
|
foreach ( keys %$c ) { |
24
|
0
|
|
0
|
|
|
0
|
$CONFIG{ $class->_root } ||= {}; |
25
|
0
|
|
|
|
|
0
|
$CONFIG{ $class->_root }->{$_} = $c->{$_}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub config { |
30
|
1
|
|
|
1
|
0
|
2
|
my $class = shift; |
31
|
1
|
|
50
|
|
|
5
|
$CONFIG{ $class->_root }->{ $ENV{COT_ENV} || "development" }; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub BEGIN { |
35
|
1
|
|
|
1
|
|
5
|
__PACKAGE__->loadconfig; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
__END__ |