blib/lib/Bot/Cobalt/Core/Role/IRC.pm untested

filter: Statementstmt 0.0% 0 / 53 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 12 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 93 SCAR 42.8
CC
8
Cov
0%
get_irc_obj
20.0
get_irc_casemap
12.0
is_connected
6.0
CRAP 72.0
1 package Bot::Cobalt::Core::Role::IRC;
2 $Bot::Cobalt::Core::Role::IRC::VERSION = '0.021002';
3 use 5.10.1;
4 use strictures 2;
5 no warnings 'once';
6  
7 use Bot::Cobalt::Common ':types';
8  
9 use Scalar::Util 'blessed';
10  
11  
12 use Moo::Role;
13 requires qw/ log debug /;
14  
15  
16 has 'Servers' => (
17 is => 'rw',
18 isa => HashRef,
19 default => sub { +{} },
20 );
21  
22  
23 sub is_connected {
24 my ($self, $context) = @_;
25 return unless $context and exists $self->Servers->{$context};
26 $self->Servers->{$context}->connected
27 }
28  
29 *get_irc_server = *get_irc_context;
30 sub get_irc_context {
31 my ($self, $context) = @_;
32 return unless defined $context and exists $self->Servers->{$context};
33 $self->Servers->{$context}
34 }
35  
36 *get_irc_object = *get_irc_obj;
37 sub get_irc_obj {
38 my ($self, $context) = @_;
39 if (! $context) {
40 $self->log->warn(
41 "get_irc_obj called with no context at "
42 .join ' ', (caller)[0,2]
43 );
44 return
45 }
46  
47 my $c_obj = $self->get_irc_context($context);
48 unless ($c_obj && blessed $c_obj) {
49 $self->log->warn(
50 "get_irc_obj called but context $context not found at "
51 .join ' ', (caller)[0,2]
52 );
53 return
54 }
55
56 blessed $c_obj->irc ? $c_obj->irc : ()
57 }
58  
59 sub get_irc_casemap {
60 my ($self, $context) = @_;
61 if (! $context) {
62 $self->log->warn(
63 "get_irc_casemap called with no context at "
64 .join ' ', (caller)[0,2]
65 );
66 return
67 }
68  
69 my $c_obj = $self->get_irc_context($context);
70 unless ($c_obj && blessed $c_obj) {
71 $self->log->warn(
72 "get_irc_casemap called but context $context not found at "
73 .join ' ', (caller)[0,2]
74 );
75 return
76 }
77  
78 $c_obj->casemap
79 }
80  
81  
82 1;
83 __END__