| 1 | package Bot::Cobalt::Conf::File::Core; | ||||||||||||||||||||||||||||
| 2 | 2 | $Bot::Cobalt::Conf::File::Core::VERSION = '0.021003'; | |||||||||||||||||||||||||||
| 3 | 2 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strictures 2; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 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 Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | extends 'Bot::Cobalt::Conf::File'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | has language => ( | ||||||||||||||||||||||||||||
| 14 | lazy => 1, | ||||||||||||||||||||||||||||
| 15 | is => 'rwp', | ||||||||||||||||||||||||||||
| 16 | isa => Str, | ||||||||||||||||||||||||||||
| 17 | 2 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 18 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 19 | 2 | ▶ | $self->cfg_as_hash->{Language} // 'english' ; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->cfg_as_hash->{"Language"} // "english"
MC/DC0%0/1
$self->cfg_as_hash->{"Language"} // "english"
$self->cfg_as_hash->{"Language"}
Truth table50%1/2
A
A= $self->cfg_as_hash->{"Language"}
| |||||||||||||||||||||||||||||
| 20 | }, | ||||||||||||||||||||||||||||
| 21 | 2 | ); | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | has paths => ( | ||||||||||||||||||||||||||||
| 24 | lazy => 1, | ||||||||||||||||||||||||||||
| 25 | weak_ref => 1, | ||||||||||||||||||||||||||||
| 26 | is => 'rwp', | ||||||||||||||||||||||||||||
| 27 | isa => HashRef, | ||||||||||||||||||||||||||||
| 28 | 1 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 29 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 30 | ref $self->cfg_as_hash->{Paths} eq 'HASH' ? | ||||||||||||||||||||||||||||
| 31 | $self->cfg_as_hash->{Paths} | ||||||||||||||||||||||||||||
| 32 | : {} | ||||||||||||||||||||||||||||
| 33 | 1 | ▶ | }, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 2 | ); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | has irc => ( | ||||||||||||||||||||||||||||
| 37 | lazy => 1, | ||||||||||||||||||||||||||||
| 38 | weak_ref => 1, | ||||||||||||||||||||||||||||
| 39 | is => 'rwp', | ||||||||||||||||||||||||||||
| 40 | isa => HashRef, | ||||||||||||||||||||||||||||
| 41 | 1 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 43 | $self->cfg_as_hash->{IRC} | ||||||||||||||||||||||||||||
| 44 | 1 | }, | |||||||||||||||||||||||||||
| 45 | 2 | ); | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | has opts => ( | ||||||||||||||||||||||||||||
| 48 | lazy => 1, | ||||||||||||||||||||||||||||
| 49 | weak_ref => 1, | ||||||||||||||||||||||||||||
| 50 | is => 'rwp', | ||||||||||||||||||||||||||||
| 51 | isa => HashRef, | ||||||||||||||||||||||||||||
| 52 | 2 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 54 | $self->cfg_as_hash->{Opts} | ||||||||||||||||||||||||||||
| 55 | 2 | }, | |||||||||||||||||||||||||||
| 56 | 2 | ); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 2 | ▶ | around 'validate' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=21.2
| |||||||||||||||||||||||||||||
| 59 | 2 | my ($orig, $self, $cfg) = @_; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 2 | my $path = $self->cfg_path; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 2 | for my $expected_hash (qw/ IRC Opts /) { | |||||||||||||||||||||||||||
| 64 | 4 | ▶ | unless (defined $cfg->{$expected_hash}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | die "Directive '$expected_hash' not found; should be a hash\n" | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 4 | ▶ | unless (ref $cfg->{$expected_hash} eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 0 | die "Directive '$expected_hash' should be a hash\n" | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 4 | ▶ | if (defined $cfg->{Paths} && ref $cfg->{Paths} ne 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $cfg->{"Paths"} and ref $cfg->{"Paths"} ne "HASH"
MC/DC0%0/2
defined $cfg->{"Paths"} and ref $cfg->{"Paths"} ne "HASH"
defined $cfg->{"Paths"}
ref $cfg->{"Paths"} ne "HASH"
Truth table33%1/3
A and B
A= defined $cfg->{"Paths"}B= ref $cfg->{"Paths"} ne "HASH"
| |||||||||||||||||||||||||||||
| 73 | 0 | die "Directive 'Paths' specified but not a hash\n" | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 1 | ||||||||||||||||||||||||||||
| 78 | 2 | }; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 2 | 1; | |||||||||||||||||||||||||||
| 82 | __END__ | ||||||||||||||||||||||||||||