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

filter: Statementstmt 60.0% 18 / 30 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 60.0% 6 / 10 Podpod 0.0% 0 / 1 totaltotal 50.0% 24 / 48 SCAR 20.9
CC
5
Cov
50%
_build_opts
30.0
__ANON__
2.0
__ANON__
2.0
CRAP 8.1
« blib/lib/Bot/Cobalt/Conf/File/Core.pm ↑ Summary blib/lib/Bot/Cobalt/Core/Role/Singleton.pm »
1 package Bot::Cobalt::Conf::File::PerPlugin;
2 $Bot::Cobalt::Conf::File::PerPlugin::VERSION = '0.021002';
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 1 ▶use Scalar::Util 'blessed';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use Types::Path::Tiny -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 0 ▶ default => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
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 0 ▶ default => sub { 1 },
Subroutine __ANON__: not called CC=1 SCAR=6.9
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 0 ▶ my ($self) = @_;
Subroutine _build_opts: not called CC=5 SCAR=34.0
67
68 ## - readfile() our config_file if we have one
69 ## - override with extra_opts if we have any
70  
71 0 my $opts_hash;
72
73 0 ▶ if ( $self->has_config_file ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_config_file) 0 0 0
74 0 $opts_hash = $self->readfile( $self->config_file )
75 }
76  
77 0 ▶ if ( $self->has_extra_opts ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_extra_opts) 0 0 0
78 ## 'Opts' directive in plugins.conf was passed in
79 $opts_hash->{$_} = $self->extra_opts->{$_}
80 0 for keys %{ $self->extra_opts };
81 }
82  
83 $opts_hash // {}
84 0 ▶}
Condition0%0/2
$opts_hash // {}
l!l
00
MC/DC0%0/1
$opts_hash // {}
$opts_hash
Truth table0%0/2
A
A= $opts_hash
Aresult
11
00
85  
86 sub reload_conf {
87 0 ▶ my ($self) = @_;
Subroutine reload_conf: not called CC=1 SCAR=6.9
Pod undocumented
88 0 $self->_set_opts( $self->_build_opts )
89 }
90  
91 1;
92 __END__
« blib/lib/Bot/Cobalt/Conf/File/Core.pm ↑ Summary blib/lib/Bot/Cobalt/Core/Role/Singleton.pm »