line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bot::Cobalt::Conf::File::Core; |
2
|
|
|
|
|
|
|
$Bot::Cobalt::Conf::File::Core::VERSION = '0.021003'; |
3
|
5
|
|
|
5
|
|
22145
|
use v5.10; |
|
5
|
|
|
|
|
12
|
|
4
|
5
|
|
|
5
|
|
581
|
use strictures 2; |
|
5
|
|
|
|
|
1682
|
|
|
5
|
|
|
|
|
152
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
728
|
use Carp; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
277
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
591
|
use Bot::Cobalt::Common ':types'; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
21
|
|
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
1856
|
use Moo; |
|
5
|
|
|
|
|
24414
|
|
|
5
|
|
|
|
|
26
|
|
11
|
|
|
|
|
|
|
extends 'Bot::Cobalt::Conf::File'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has language => ( |
14
|
|
|
|
|
|
|
lazy => 1, |
15
|
|
|
|
|
|
|
is => 'rwp', |
16
|
|
|
|
|
|
|
isa => Str, |
17
|
|
|
|
|
|
|
default => sub { |
18
|
|
|
|
|
|
|
my ($self) = @_; |
19
|
|
|
|
|
|
|
$self->cfg_as_hash->{Language} // 'english' ; |
20
|
|
|
|
|
|
|
}, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has paths => ( |
24
|
|
|
|
|
|
|
lazy => 1, |
25
|
|
|
|
|
|
|
weak_ref => 1, |
26
|
|
|
|
|
|
|
is => 'rwp', |
27
|
|
|
|
|
|
|
isa => HashRef, |
28
|
|
|
|
|
|
|
default => sub { |
29
|
|
|
|
|
|
|
my ($self) = @_; |
30
|
|
|
|
|
|
|
ref $self->cfg_as_hash->{Paths} eq 'HASH' ? |
31
|
|
|
|
|
|
|
$self->cfg_as_hash->{Paths} |
32
|
|
|
|
|
|
|
: {} |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has irc => ( |
37
|
|
|
|
|
|
|
lazy => 1, |
38
|
|
|
|
|
|
|
weak_ref => 1, |
39
|
|
|
|
|
|
|
is => 'rwp', |
40
|
|
|
|
|
|
|
isa => HashRef, |
41
|
|
|
|
|
|
|
default => sub { |
42
|
|
|
|
|
|
|
my ($self) = @_; |
43
|
|
|
|
|
|
|
$self->cfg_as_hash->{IRC} |
44
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has opts => ( |
48
|
|
|
|
|
|
|
lazy => 1, |
49
|
|
|
|
|
|
|
weak_ref => 1, |
50
|
|
|
|
|
|
|
is => 'rwp', |
51
|
|
|
|
|
|
|
isa => HashRef, |
52
|
|
|
|
|
|
|
default => sub { |
53
|
|
|
|
|
|
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
$self->cfg_as_hash->{Opts} |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
around 'validate' => sub { |
59
|
|
|
|
|
|
|
my ($orig, $self, $cfg) = @_; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $path = $self->cfg_path; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
for my $expected_hash (qw/ IRC Opts /) { |
64
|
|
|
|
|
|
|
unless (defined $cfg->{$expected_hash}) { |
65
|
|
|
|
|
|
|
die "Directive '$expected_hash' not found; should be a hash\n" |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
unless (ref $cfg->{$expected_hash} eq 'HASH') { |
69
|
|
|
|
|
|
|
die "Directive '$expected_hash' should be a hash\n" |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
if (defined $cfg->{Paths} && ref $cfg->{Paths} ne 'HASH') { |
73
|
|
|
|
|
|
|
die "Directive 'Paths' specified but not a hash\n" |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1 |
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
__END__ |