line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bot::Cobalt::Conf::File; |
2
|
|
|
|
|
|
|
$Bot::Cobalt::Conf::File::VERSION = '0.021002'; |
3
|
8
|
|
|
8
|
|
16155
|
use v5.10; |
|
8
|
|
|
|
|
20
|
|
4
|
8
|
|
|
8
|
|
398
|
use strictures 2; |
|
8
|
|
|
|
|
1427
|
|
|
8
|
|
|
|
|
251
|
|
5
|
8
|
|
|
8
|
|
1132
|
use Carp; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
432
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
373
|
use Bot::Cobalt::Common ':types'; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
39
|
|
8
|
8
|
|
|
8
|
|
2266
|
use Bot::Cobalt::Serializer; |
|
8
|
|
|
|
|
83
|
|
|
8
|
|
|
|
|
214
|
|
9
|
|
|
|
|
|
|
|
10
|
8
|
|
|
8
|
|
38
|
use Try::Tiny; |
|
8
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
363
|
|
11
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
2746
|
use Types::Path::Tiny -types; |
|
8
|
|
|
|
|
109638
|
|
|
8
|
|
|
|
|
66
|
|
13
|
|
|
|
|
|
|
|
14
|
8
|
|
|
8
|
|
4718
|
use List::Objects::WithUtils; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
59
|
|
15
|
8
|
|
|
8
|
|
7926
|
use List::Objects::Types -types; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
46
|
|
16
|
|
|
|
|
|
|
|
17
|
8
|
|
|
8
|
|
5965
|
use Moo; |
|
8
|
|
|
|
|
10
|
|
|
8
|
|
|
|
|
42
|
|
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
|
|
2377
|
builder => sub { 0 }, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub BUILD { |
43
|
10
|
|
|
10
|
0
|
1660
|
my ($self) = @_; |
44
|
10
|
|
|
|
|
108
|
$self->cfg_as_hash |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _build_cfg_hash { |
48
|
11
|
|
|
11
|
|
3603
|
my ($self) = @_; |
49
|
|
|
|
|
|
|
|
50
|
11
|
100
|
|
|
|
109
|
if ($self->debug) { |
51
|
1
|
|
|
|
|
445
|
warn |
52
|
|
|
|
|
|
|
ref $self, " (debug) reading cfg_as_hash from ", $self->cfg_path, "\n" |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
11
|
|
|
|
|
2354
|
my $cfg = $self->readfile( $self->cfg_path ); |
56
|
|
|
|
|
|
|
|
57
|
11
|
|
|
|
|
15
|
my $err; try { |
58
|
11
|
|
|
11
|
|
525
|
$self->validate($cfg) |
59
|
|
|
|
|
|
|
} catch { |
60
|
0
|
|
|
0
|
|
0
|
$err = $_; |
61
|
|
|
|
|
|
|
undef |
62
|
11
|
50
|
|
|
|
63
|
} or croak "Conf validation failed for ". $self->cfg_path .": $err"; |
|
0
|
|
|
|
|
0
|
|
63
|
|
|
|
|
|
|
|
64
|
11
|
|
|
|
|
138
|
$cfg |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub rehash { |
68
|
1
|
|
|
1
|
1
|
1757
|
my ($self) = @_; |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
3
|
$self->_set_cfg_as_hash( $self->_build_cfg_hash ) |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub validate { |
74
|
2
|
|
|
2
|
0
|
3
|
my ($self, $cfg) = @_; |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
5
|
1 |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
__END__ |