| 1 | package App::derived::Plugin; | ||||||||||||
| 2 | |||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 8 | ▶ | use Class::Accessor::Lite ( | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 8 | new => 1, | |||||||||||
| 7 | ro => [qw/_services _proclet/] | ||||||||||||
| 8 | 8 | ); | |||||||||||
| 9 | 8 | ▶ | use JSON qw//; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 8 | my $_JSON = JSON->new() | |||||||||||
| 12 | ->utf8(1) | ||||||||||||
| 13 | ->shrink(1) | ||||||||||||
| 14 | ->space_before(0) | ||||||||||||
| 15 | ->space_after(0) | ||||||||||||
| 16 | ->indent(0); | ||||||||||||
| 17 | |||||||||||||
| 18 | 4 | ▶ | sub json { | ||||||||||
|
Subroutine
json: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 19 | 4 | $_JSON; | |||||||||||
| 20 | } | ||||||||||||
| 21 | |||||||||||||
| 22 | 0 | ▶ | sub exists_service { | ||||||||||
|
Subroutine
exists_service: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 23 | 0 | my $self = shift; | |||||||||||
| 24 | 0 | my $key = shift; | |||||||||||
| 25 | 0 | exists $self->_services->{$key}; | |||||||||||
| 26 | } | ||||||||||||
| 27 | |||||||||||||
| 28 | 2 | ▶ | sub service_stats { | ||||||||||
|
Subroutine
service_stats: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||
| 29 | 2 | my $self = shift; | |||||||||||
| 30 | 2 | my $key = shift; | |||||||||||
| 31 | 2 | ▶ | return if ! exists $self->_services->{$key}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 32 | 2 | my $service = $self->_services->{$key}; | |||||||||||
| 33 | 2 | ▶ | open my $fh, '<', $service->{file} or return; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 34 | 2 | my $val = do { local $/; <$fh> }; | |||||||||||
| 35 | 2 | $self->json->decode($val); | |||||||||||
| 36 | } | ||||||||||||
| 37 | |||||||||||||
| 38 | 1 | ▶ | sub service_keys { | ||||||||||
|
Subroutine
service_keys: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 39 | 1 | my $self = shift; | |||||||||||
| 40 | 1 | keys %{$self->_services}; | |||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | 8 | my %worker_tag; | |||||||||||
| 44 | 8 | ▶ | sub add_worker { | ||||||||||
|
Subroutine
add_worker: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||
| 45 | 8 | my $self = shift; | |||||||||||
| 46 | 8 | my ($tag, $code, $workers) = @_; | |||||||||||
| 47 | 8 | ▶ | $workers ||= 1; | ||||||||||
|
Condition50%1/2
$workers ||= 1
MC/DC0%0/1
$workers ||= 1
$workers
Truth table50%1/2
A
A= $workers
| |||||||||||||
| 48 | 8 | ▶ | $worker_tag{$tag} = 0 unless exists $worker_tag{$tag}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 49 | 8 | $worker_tag{$tag}++; | |||||||||||
| 50 | $self->_proclet->service( | ||||||||||||
| 51 | code => $code, | ||||||||||||
| 52 | 8 | tag => $tag . '_' . $worker_tag{$tag}, | |||||||||||
| 53 | worker => $workers | ||||||||||||
| 54 | ); | ||||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | 0 | ▶ | sub init { | ||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 58 | 0 | die 'abstract method'; | |||||||||||
| 59 | } | ||||||||||||
| 60 | |||||||||||||
| 61 | |||||||||||||
| 62 | 8 | 1; | |||||||||||
| 63 | |||||||||||||
| 64 | __END__ | ||||||||||||