blib/lib/Bot/Cobalt/Conf/File/PerPlugin.pm

filter: Statementstmt 97.4% 38 / 39 Branchbran 100% 4 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 1 totaltotal 91.2% 52 / 57 CC 5 SCAR 9.2
CC
5
Cov
96%
_build_opts
5.0
__ANON__
2.0
BEGIN
1.0
CRAP 2.5
« blib/lib/Bot/Cobalt/Logger.pm ↑ Summary blib/lib/Bot/Cobalt/Conf/File/Channels.pm »
1 package Bot::Cobalt::Conf::File::PerPlugin;
2 2 $Bot::Cobalt::Conf::File::PerPlugin::VERSION = '0.021003';
3 ## This is in File:: but NOT a subclass of File.pm
4  
5 2 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Bot::Cobalt::Common ':types';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Scalar::Util 'blessed';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use Types::Path::Tiny -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 with 'Bot::Cobalt::Conf::Role::Reader';
16  
17  
18 2 has module => (
19 required => 1,
20 is => 'rwp',
21 isa => Str,
22 );
23  
24 2 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 0 ▶ default => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 2 );
41  
42 2 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 1 ▶ default => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
56 2 );
57  
58 2 has opts => (
59 lazy => 1,
60 is => 'rwp',
61 isa => HashRef,
62 builder => '_build_opts',
63 );
64  
65 4 ▶sub _build_opts {
Subroutine _build_opts: called CC=5 SCAR=16.1
66 4 my ($self) = @_;
67
68 ## - readfile() our config_file if we have one
69 ## - override with extra_opts if we have any
70  
71 4 my $opts_hash;
72
73 4 ▶ if ( $self->has_config_file ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_config_file) 1 3 4
74 1 $opts_hash = $self->readfile( $self->config_file )
75 }
76  
77 4 ▶ if ( $self->has_extra_opts ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_extra_opts) 3 1 4
78 ## 'Opts' directive in plugins.conf was passed in
79 $opts_hash->{$_} = $self->extra_opts->{$_}
80 3 for keys %{ $self->extra_opts };
81 }
82  
83 $opts_hash // {}
84 4 ▶}
Condition50%1/2
$opts_hash // {}
l!l
40
MC/DC0%0/1
$opts_hash // {}
$opts_hash
Truth table50%1/2
A
A= $opts_hash
Aresult
11
00
85  
86 1 ▶sub reload_conf {
Subroutine reload_conf: called CC=1 SCAR=0.0
Pod undocumented
87 1 my ($self) = @_;
88 1 $self->_set_opts( $self->_build_opts )
89 }
90  
91 2 1;
92 __END__
« blib/lib/Bot/Cobalt/Logger.pm ↑ Summary blib/lib/Bot/Cobalt/Conf/File/Channels.pm »