line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bot::Cobalt::Conf::File::PerPlugin; |
2
|
|
|
|
|
|
|
$Bot::Cobalt::Conf::File::PerPlugin::VERSION = '0.021003'; |
3
|
|
|
|
|
|
|
## This is in File:: but NOT a subclass of File.pm |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
17
|
use strictures 2; |
|
5
|
|
|
|
|
25
|
|
|
5
|
|
|
|
|
165
|
|
6
|
5
|
|
|
5
|
|
722
|
use Carp; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
223
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
19
|
use Bot::Cobalt::Common ':types'; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
22
|
|
9
|
|
|
|
|
|
|
|
10
|
5
|
|
|
5
|
|
26
|
use Scalar::Util 'blessed'; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
244
|
|
11
|
|
|
|
|
|
|
|
12
|
5
|
|
|
5
|
|
421
|
use Types::Path::Tiny -types; |
|
5
|
|
|
|
|
17930
|
|
|
5
|
|
|
|
|
34
|
|
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
5
|
|
3107
|
use Moo; |
|
5
|
|
|
|
|
6059
|
|
|
5
|
|
|
|
|
23
|
|
15
|
|
|
|
|
|
|
with 'Bot::Cobalt::Conf::Role::Reader'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has module => ( |
19
|
|
|
|
|
|
|
required => 1, |
20
|
|
|
|
|
|
|
is => 'rwp', |
21
|
|
|
|
|
|
|
isa => Str, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has extra_opts => ( |
25
|
|
|
|
|
|
|
## Overrides the plugin-specific cfg. |
26
|
|
|
|
|
|
|
lazy => 1, |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
isa => HashRef, |
29
|
|
|
|
|
|
|
predicate => 'has_extra_opts', |
30
|
|
|
|
|
|
|
writer => 'set_extra_opts', |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has priority => ( |
34
|
|
|
|
|
|
|
lazy => 1, |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
isa => Num, |
37
|
|
|
|
|
|
|
writer => 'set_priority', |
38
|
|
|
|
|
|
|
predicate => 'has_priority', |
39
|
|
|
|
|
|
|
default => sub { 1 }, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has config_file => ( |
43
|
|
|
|
|
|
|
lazy => 1, |
44
|
|
|
|
|
|
|
is => 'ro', |
45
|
|
|
|
|
|
|
isa => Path, |
46
|
|
|
|
|
|
|
coerce => 1, |
47
|
|
|
|
|
|
|
writer => 'set_config_file', |
48
|
|
|
|
|
|
|
predicate => 'has_config_file', |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has autoload => ( |
52
|
|
|
|
|
|
|
lazy => 1, |
53
|
|
|
|
|
|
|
is => 'ro', |
54
|
|
|
|
|
|
|
isa => Bool, |
55
|
|
|
|
|
|
|
default => sub { 1 }, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has opts => ( |
59
|
|
|
|
|
|
|
lazy => 1, |
60
|
|
|
|
|
|
|
is => 'rwp', |
61
|
|
|
|
|
|
|
isa => HashRef, |
62
|
|
|
|
|
|
|
builder => '_build_opts', |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _build_opts { |
66
|
4
|
|
|
4
|
|
641
|
my ($self) = @_; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
## - readfile() our config_file if we have one |
69
|
|
|
|
|
|
|
## - override with extra_opts if we have any |
70
|
|
|
|
|
|
|
|
71
|
4
|
|
|
|
|
4
|
my $opts_hash; |
72
|
|
|
|
|
|
|
|
73
|
4
|
100
|
|
|
|
15
|
if ( $self->has_config_file ) { |
74
|
1
|
|
|
|
|
9
|
$opts_hash = $self->readfile( $self->config_file ) |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
4
|
100
|
|
|
|
12
|
if ( $self->has_extra_opts ) { |
78
|
|
|
|
|
|
|
## 'Opts' directive in plugins.conf was passed in |
79
|
|
|
|
|
|
|
$opts_hash->{$_} = $self->extra_opts->{$_} |
80
|
3
|
|
|
|
|
2
|
for keys %{ $self->extra_opts }; |
|
3
|
|
|
|
|
21
|
|
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$opts_hash // {} |
84
|
4
|
|
50
|
|
|
47
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub reload_conf { |
87
|
1
|
|
|
1
|
0
|
8
|
my ($self) = @_; |
88
|
1
|
|
|
|
|
2
|
$self->_set_opts( $self->_build_opts ) |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
__END__ |