blib/lib/Aion/Emitter/ListenersRun.pm

filter: Statementstmt 96.6% 29 / 30 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 95.1% 39 / 41 CC 4 SCAR 8.5
CC
4
Cov
94%
list
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.3
« blib/lib/Aion/Emitter.pm ↑ Summary /tmp/.liveman/Aion-Emitter-0.1.2-0/aion!emitter.t/lib/Listener/WeightListener.pm »
1 package Aion::Emitter::ListenersRun;
2 # Список слушателей
3  
4 1 ▶use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use List::Util qw/pairmap max/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Aion::Format qw/printcolor/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Aion;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 with qw/Aion::Run/;
11  
12 # Маска для фильтра по командам
13 1 has mask => (is => 'ro', isa => Maybe[Str], arg => 1);
14  
15 # Эмиттер
16 1 has emitter => (is => 'ro', isa => 'Aion::Emitter', eon => 1);
17  
18 #@run emit:listeners „List of listeners”
19 1 ▶sub list {
Subroutine list: called CC=4 SCAR=13.9
Pod documented
20 1 my ($self) = @_;
21
22 3 ▶ my @listeners = sort { $a->{evt} eq $b->{evt}? $a->{nice} <=> $b->{nice}: $a->{evt} cmp $b->{evt} }
Branch: 1 branch
BranchTrueFalseTotal
$Aion::Emitter::ListenersRun::a->{'evt'} eq $Aion::Emitter::ListenersRun::b->{'evt'} ? : 1 2 3
23 2 ▶ pairmap { my $evt = $a; map { +{ %$_, evt => $evt, act => $_->{act}, nice => 0+$_->{nice} } } @$b }
Subroutine __ANON__: called CC=1 SCAR=0.0
24 1 %{$self->emitter->event};
25
26 1 ▶ @listeners = grep { /$self->{mask}/ } @listeners if $self->mask ne "";
Branch: 1 branch
BranchTrueFalseTotal
if $self->mask ne "" 0 1 1
27 1 my $evtlen = max map length $_->{evt}, @listeners;
28 1 my $actlen = max map length $_->{act}, @listeners;
29 1 my $nicelen = max map length $_->{nice}, @listeners;
30 1 for my $listener_bag (@listeners) {
31 3 printcolor "#{blue}%+${nicelen}s#r #green%-${evtlen}s #{red}%-${actlen}s #{bold black}%s#r\n", @$listener_bag{qw/nice evt act remark/};
32 }
33 }
34  
35 1 1;
36  
37 __END__
« blib/lib/Aion/Emitter.pm ↑ Summary /tmp/.liveman/Aion-Emitter-0.1.2-0/aion!emitter.t/lib/Listener/WeightListener.pm »