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

filter: Statementstmt 84.7% 39 / 46 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 82.3% 14 / 17 Podpod 33.3% 1 / 3 totaltotal 80.0% 56 / 70 SCAR 11.2
CC
3
Cov
82%
_build_cfg_hash
3.4
rehash
2.0
validate
2.0
CRAP 3.1
« blib/lib/Bot/Cobalt/Plugin/OutputFilters/StripColor.pm ↑ Summary blib/lib/Bot/Cobalt/Conf/Role/Reader.pm »
1 package Bot::Cobalt::Conf::File;
2 $Bot::Cobalt::Conf::File::VERSION = '0.021002';
3 3 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use Bot::Cobalt::Common ':types';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Bot::Cobalt::Serializer;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Try::Tiny;
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 List::Objects::WithUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use List::Objects::Types -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 1 ▶ builder => sub { 0 },
Subroutine _build_debug: called CC=1 SCAR=0.0
40 );
41  
42 sub BUILD {
43 4 ▶ my ($self) = @_;
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
44 4 $self->cfg_as_hash
45 }
46  
47 sub _build_cfg_hash {
48 4 ▶ my ($self) = @_;
Subroutine _build_cfg_hash: called CC=3 SCAR=12.3
49  
50 4 ▶ if ($self->debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->debug) 0 4 4
51 0 warn
52 ref $self, " (debug) reading cfg_as_hash from ", $self->cfg_path, "\n"
53 }
54
55 4 my $cfg = $self->readfile( $self->cfg_path );
56  
57 4 my $err; try {
58 4 ▶ $self->validate($cfg)
Subroutine __ANON__: called CC=1 SCAR=0.0
59 } catch {
60 0 ▶ $err = $_;
Subroutine __ANON__: not called CC=1 SCAR=2.0
61 undef
62 4 ▶ } or croak "Conf validation failed for ". $self->cfg_path .": $err";
Branch: 1 branch
BranchTrueFalseTotal
&try(sub { $self->validate($cfg); } , &catch(sub { $err = $_; undef; } )) or croak('Conf validation failed for ' . $self->cfg_path . ": $err") 0 4 4
63  
64 4 $cfg
65 }
66  
67 sub rehash {
68 0 ▶ my ($self) = @_;
Subroutine rehash: not called CC=1 SCAR=6.9
Pod documented
69
70 0 $self->_set_cfg_as_hash( $self->_build_cfg_hash )
71 }
72  
73 sub validate {
74 0 ▶ my ($self, $cfg) = @_;
Subroutine validate: not called CC=1 SCAR=6.9
Pod undocumented
75
76 0 1
77 }
78  
79 1;
80 __END__
« blib/lib/Bot/Cobalt/Plugin/OutputFilters/StripColor.pm ↑ Summary blib/lib/Bot/Cobalt/Conf/Role/Reader.pm »