line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bot::Cobalt::Conf::File; |
2
|
|
|
|
|
|
|
$Bot::Cobalt::Conf::File::VERSION = '0.021003'; |
3
|
8
|
|
|
8
|
|
19587
|
use v5.10; |
|
8
|
|
|
|
|
19
|
|
4
|
8
|
|
|
8
|
|
402
|
use strictures 2; |
|
8
|
|
|
|
|
1356
|
|
|
8
|
|
|
|
|
275
|
|
5
|
8
|
|
|
8
|
|
1278
|
use Carp; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
433
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
522
|
use Bot::Cobalt::Common ':types'; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
44
|
|
8
|
8
|
|
|
8
|
|
2457
|
use Bot::Cobalt::Serializer; |
|
8
|
|
|
|
|
75
|
|
|
8
|
|
|
|
|
257
|
|
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
52
|
use Try::Tiny; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
422
|
|
11
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
3346
|
use Types::Path::Tiny -types; |
|
8
|
|
|
|
|
121485
|
|
|
8
|
|
|
|
|
78
|
|
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
|
5152
|
use List::Objects::WithUtils; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
66
|
|
15
|
8
|
|
|
8
|
|
8105
|
use List::Objects::Types -types; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
53
|
|
16
|
|
|
|
|
|
|
|
17
|
8
|
|
|
8
|
|
6396
|
use Moo; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
53
|
|
18
|
|
|
|
|
|
|
with 'Bot::Cobalt::Conf::Role::Reader'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has cfg_path => ( |
22
|
|
|
|
|
|
|
required => 1, |
23
|
|
|
|
|
|
|
is => 'rwp', |
24
|
|
|
|
|
|
|
isa => Path, |
25
|
|
|
|
|
|
|
coerce => 1, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has cfg_as_hash => ( |
29
|
|
|
|
|
|
|
lazy => 1, |
30
|
|
|
|
|
|
|
is => 'rwp', |
31
|
|
|
|
|
|
|
isa => HashObj, |
32
|
|
|
|
|
|
|
coerce => 1, |
33
|
|
|
|
|
|
|
builder => '_build_cfg_hash', |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has debug => ( |
37
|
|
|
|
|
|
|
is => 'rw', |
38
|
|
|
|
|
|
|
isa => Bool, |
39
|
3
|
|
|
3
|
|
3073
|
builder => sub { 0 }, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub BUILD { |
43
|
10
|
|
|
10
|
0
|
1741
|
my ($self) = @_; |
44
|
10
|
|
|
|
|
146
|
$self->cfg_as_hash |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _build_cfg_hash { |
48
|
11
|
|
|
11
|
|
3884
|
my ($self) = @_; |
49
|
|
|
|
|
|
|
|
50
|
11
|
100
|
|
|
|
117
|
if ($self->debug) { |
51
|
1
|
|
|
|
|
452
|
warn |
52
|
|
|
|
|
|
|
ref $self, " (debug) reading cfg_as_hash from ", $self->cfg_path, "\n" |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
11
|
|
|
|
|
2406
|
my $cfg = $self->readfile( $self->cfg_path ); |
56
|
|
|
|
|
|
|
|
57
|
11
|
|
|
|
|
14
|
my $err; try { |
58
|
11
|
|
|
11
|
|
602
|
$self->validate($cfg) |
59
|
|
|
|
|
|
|
} catch { |
60
|
0
|
|
|
0
|
|
0
|
$err = $_; |
61
|
|
|
|
|
|
|
undef |
62
|
11
|
50
|
|
|
|
172
|
} or croak "Conf validation failed for ". $self->cfg_path .": $err"; |
|
0
|
|
|
|
|
0
|
|
63
|
|
|
|
|
|
|
|
64
|
11
|
|
|
|
|
163
|
$cfg |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub rehash { |
68
|
1
|
|
|
1
|
1
|
2024
|
my ($self) = @_; |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
3
|
$self->_set_cfg_as_hash( $self->_build_cfg_hash ) |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub validate { |
74
|
2
|
|
|
2
|
0
|
2
|
my ($self, $cfg) = @_; |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
4
|
1 |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
__END__ |