blib/lib/Bot/Cobalt/IRC/Event.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 32 / 32 CC 3 SCAR 5.6
CC
3
Cov
100%
__ANON__
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.8
« blib/lib/Bot/Cobalt/Plugin/OutputFilters/StripFormat.pm ↑ Summary blib/lib/Bot/Cobalt/Core/Role/Singleton.pm »
1 package Bot::Cobalt::IRC::Event;
2 2 $Bot::Cobalt::IRC::Event::VERSION = '0.021003';
3 ## Base class for IRC events.
4  
5 2 ▶use Bot::Cobalt::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 has context => (
10 required => 1,
11 is => 'rw',
12 isa => Str,
13 );
14  
15 has src => (
16 required => 1,
17 is => 'rw',
18 isa => Str,
19 2 ▶ trigger => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
20 ## If 'src' changes, reset nick/user/host as-needed.
21 2 my ($self, $value) = @_;
22
23 2 my @types = qw/nick user host/;
24 2 my %pieces;
25 2 @pieces{@types} = parse_user($value);
26
27 2 for my $type (@types) {
28 6 my $meth = '_set_src_'.$type;
29 6 my $hasmeth = 'has_src_'.$type;
30 6 ▶ $self->$meth($pieces{$type}) if $self->$hasmeth;
Branch: 1 branch
BranchTrueFalseTotal
if $self->$hasmeth 3 3 6
31 }
32 }
33 2 );
34  
35 has src_nick => (
36 lazy => 1,
37 is => 'rwp',
38 predicate => 'has_src_nick',
39 1 ▶ default => sub { (parse_user($_[0]->src))[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
40 2 );
41  
42 has src_user => (
43 lazy => 1,
44 is => 'rwp',
45 predicate => 'has_src_user',
46 1 ▶ default => sub { (parse_user($_[0]->src))[1] },
Subroutine __ANON__: called CC=1 SCAR=0.0
47 2 );
48  
49 has src_host => (
50 lazy => 1,
51 is => 'rwp',
52 predicate => 'has_src_host',
53 1 ▶ default => sub { (parse_user($_[0]->src))[2] },
Subroutine __ANON__: called CC=1 SCAR=0.0
54 2 );
55  
56 2 1;
57 __END__
« blib/lib/Bot/Cobalt/Plugin/OutputFilters/StripFormat.pm ↑ Summary blib/lib/Bot/Cobalt/Core/Role/Singleton.pm »