Remote/Sereal.pm

filter: Statementstmt 97.6% 41 / 42 Branchbran 66.6% 8 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 4 totaltotal 87.1% 61 / 70 CC 7 SCAR 10.6
CC
7
Cov
91%
buf2rpc
6.3
init
2.0
BEGIN
1.0
CRAP 2.9
« Remote/Storable.pm ↑ Summary Remote/Protocol.pm »
1 package Net::IMP::Remote::Sereal;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Net::IMP::Remote::Protocol;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Net::IMP qw(:DEFAULT :log);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Net::IMP::Debug;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Net::IMP::Remote::DualvarMapping;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Sereal::Encoder 0.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Sereal::Decoder 0.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 my $wire_version = 0x00000001;
13  
14 sub new {
15 1 ▶ bless {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
16 encoder => Sereal::Encoder->new,
17 decoder => Sereal::Decoder->new({ incremental => 1 }),
18 }, shift;
19 }
20  
21 sub buf2rpc {
22 35 ▶ my ($self,$rdata) = @_;
Subroutine buf2rpc: called CC=6 SCAR=18.4
Pod undocumented
23 35 decode:
24 my $out = undef;
25 35 ▶ eval { $self->{decoder}->decode( $$rdata, $out ) } or return;
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $self->{"decoder"}->decode($$rdata, $out) } } or return 23 12 35
26 12 ▶ return if ! $out;
Branch: 1 branch
BranchTrueFalseTotal
unless $out 0 12 12
27 12 ▶ if ( $out->[0] == IMPRPC_SET_VERSION ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($out->[0] == "set_version") 1 11 12
28 1 ▶ die "wrong version $out->[1], can do $wire_version only"
Branch: 1 branch
BranchTrueFalseTotal
if $out->[1] != $wire_version 0 1 1
29 if $out->[1] != $wire_version;
30 1 ▶ return if $$rdata eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $$rdata eq "" 1 0 1
31 0 goto decode;
32 }
33 11 return rpc_i2d($out);
34 }
35  
36 sub rpc2buf {
37 12 ▶ my ($self,$rpc) = @_;
Subroutine rpc2buf: called CC=1 SCAR=0.0
Pod undocumented
38 12 $self->{encoder}->encode(rpc_d2i($rpc))
39 }
40  
41 sub init {
42 1 ▶ my ($self,$side) = @_;
Subroutine init: called CC=2 SCAR=7.1
Pod undocumented
43 1 ▶ return if $side == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $side == 0 0 1 1
44 1 $self->rpc2buf([IMPRPC_SET_VERSION,$wire_version])
45 }
46  
47 2 1;
« Remote/Storable.pm ↑ Summary Remote/Protocol.pm »