Tangence/Protocol.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 8 / 8 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 9 / 9 Podpod 100% 3 / 3 totaltotal 100% 57 / 57 CC 6 SCAR 7.6
CC
6
Cov
100%
__ANON__
4.0
_init
2.0
configure
2.0
CRAP 2.1
« Tangence/Client.pm ↑ Summary Tangence.pm »
1 # You may distribute under the terms of either the GNU General Public License
2 # or the Artistic License (the same terms as Perl itself)
3 #
4 # (C) Paul Evans, 2010-2011 -- leonerd@leonerd.org.uk
5  
6 package Net::Async::Tangence::Protocol 0.16;
7  
8 10 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 10 ▶use base qw( IO::Async::Stream Tangence::Stream );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 10 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 =head1 NAME
16  
17 C<Net::Async::Tangence::Protocol> - concrete implementation of
18 C<Tangence::Stream> for C<IO::Async>
19  
20 =head1 DESCRIPTION
21  
22 This subclass of L<IO::Async::Stream> provides a concrete implementation of
23 the L<Tangence::Stream> mixin. It is not intended to be directly used by
24 server implementations. Instead, it is subclassed as
25 L<Net::Async::Tangence::Client> and L<Net::Async::Tangence::ServerProtocol>.
26  
27 =cut
28  
29 sub _init
30 15 ▶{
Subroutine _init: called CC=2 SCAR=6.9
31 15 my $self = shift;
32 15 my ( $params ) = @_;
33  
34 15 $self->SUPER::_init( $params );
35  
36 15 ▶ $params->{on_closed} ||= undef;
Condition100%2/2
$params->{"on_closed"} ||= undef
l!l
78
MC/DC100%1/1
$params->{"on_closed"} ||= undef
$params->{"on_closed"}
Truth table100%2/2
A
A= $params->{"on_closed"}
Aresult
11
00
37 }
38  
39 sub configure
40 28 ▶{
Subroutine configure: called CC=2 SCAR=6.9
Pod documented
41 28 my $self = shift;
42 28 my %params = @_;
43  
44 28 ▶ if( exists $params{on_closed} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $params{"on_closed"}) 16 12 28
45 16 my $on_closed = delete $params{on_closed};
46  
47 4 ▶ $params{on_closed} = sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
48 4 my ( $self ) = @_;
49 4 ▶ $on_closed->( $self ) if $on_closed;
Branch: 1 branch
BranchTrueFalseTotal
if $on_closed 3 1 4
50  
51 4 $self->tangence_closed;
52  
53 4 ▶ if( my $parent = $self->parent ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $parent = $self->parent) { } 1 3 4
elsif (my $loop = $self->get_loop) { } 1 2 3
54 1 $parent->remove_child( $self );
55 }
56 elsif( my $loop = $self->get_loop ) {
57 1 $loop->remove( $self );
58 }
59 16 };
60 }
61  
62 28 $self->SUPER::configure( %params );
63 }
64  
65 sub tangence_write
66 58 ▶{
Subroutine tangence_write: called CC=1 SCAR=0.0
Pod documented
67 58 my $self = shift;
68 58 $self->write( $_[0] );
69 }
70  
71 sub on_read
72 47 ▶{
Subroutine on_read: called CC=1 SCAR=0.0
Pod documented
73 47 my $self = shift;
74 47 my ( $buffref, $closed ) = @_;
75  
76 47 $self->tangence_readfrom( $$buffref );
77  
78 47 return 0;
79 }
80  
81 =head1 AUTHOR
82  
83 Paul Evans <leonerd@leonerd.org.uk>
84  
85 =cut
86  
87 10 0x55AA;
« Tangence/Client.pm ↑ Summary Tangence.pm »