| 1 | package App::BCSSH::Handler; | ||||||||||||||||||||
| 2 | 1 | ▶ | use Moo::Role; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use JSON qw(encode_json decode_json); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use App::BCSSH::Message; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use MooX::CaptainHook qw(on_application); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | my %handlers; | |||||||||||||||||||
| 8 | 0 | ▶ | sub handlers { | ||||||||||||||||||
|
Subroutine
handlers: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 9 | 0 | return %handlers; | |||||||||||||||||||
| 10 | } | ||||||||||||||||||||
| 11 | 3 | ▶ | on_application { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 3 | my $class = $_; | |||||||||||||||||||
| 13 | 3 | $handlers{$class->command} = $class; | |||||||||||||||||||
| 14 | 1 | }; | |||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 1 | has host => (is => 'ro', required => 1); | |||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 3 | ▶ | sub command { | ||||||||||||||||||
|
Subroutine
command: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||
| 19 | 3 | ▶ | my $class = ref $_[0] || $_[0]; | ||||||||||||||||||
|
Condition33%1/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||
| 20 | 3 | $class =~ s/^\Q${\__PACKAGE__}:://; | |||||||||||||||||||
| 21 | 3 | return $class; | |||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 0 | ▶ | sub handle_message { | ||||||||||||||||||
|
Subroutine
handle_message: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 25 | 0 | my ($self, $args, $send, $socket) = @_; | |||||||||||||||||||
| 26 | 0 | ▶ | my $json_send = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 27 | 0 | my @response = @_; | |||||||||||||||||||
| 28 | 0 | ▶ | my $rmessage = @response ? encode_json(\@response) : ''; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | 0 | $send->(BCSSH_SUCCESS, $rmessage); | |||||||||||||||||||
| 30 | 0 | return $socket; | |||||||||||||||||||
| 31 | 0 | }; | |||||||||||||||||||
| 32 | 0 | my $handler_args = decode_json($args); | |||||||||||||||||||
| 33 | 0 | $self->handle($json_send, @$handler_args); | |||||||||||||||||||
| 34 | 0 | return; | |||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | ▶ | sub handler { | ||||||||||||||||||
|
Subroutine
handler: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 38 | 0 | my $self = shift; | |||||||||||||||||||
| 39 | 0 | ▶ | return sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 40 | 0 | my ($args, $send, $socket) = @_; | |||||||||||||||||||
| 41 | 0 | $self->handle_message($args, $send, $socket); | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | 0 | } | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 1 | 1; | |||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||