Remote/Storable.pm

filter: Statementstmt 97.6% 42 / 43 Branchbran 75.0% 9 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 4 totaltotal 88.5% 62 / 70 CC 7 SCAR 10.7
CC
7
Cov
93%
buf2rpc
6.1
init
2.0
BEGIN
1.0
CRAP 2.9
« Remote/DualvarMapping.pm ↑ Summary Remote/Sereal.pm »
1 package Net::IMP::Remote::Storable;
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 Storable ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 my $wire_version = 0x00000001;
12  
13 sub new {
14 1 ▶ bless {}, shift;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
15 }
16  
17 sub buf2rpc {
18 46 ▶ my ($self,$rdata) = @_;
Subroutine buf2rpc: called CC=6 SCAR=18.1
Pod undocumented
19 46 ▶ decode:
Branch: 1 branch
BranchTrueFalseTotal
if length $$rdata < 6 4 42 46
20 return if length($$rdata)<6;
21 42 my ($len) = unpack("x2L",$$rdata);
22 42 ▶ return if length($$rdata) - 6 < $len;
Branch: 1 branch
BranchTrueFalseTotal
if length($$rdata) - 6 < $len 30 12 42
23 12 my ($op,$args) = unpack("SL/a*",$$rdata);
24 12 substr($$rdata,0,$len+6,'');
25 12 $args = Storable::thaw($args);
26 12 ▶ if ( $op == IMPRPC_SET_VERSION ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op == "set_version") 1 11 12
27 1 ▶ die "wrong version $args->[0], can do $wire_version only"
Branch: 1 branch
BranchTrueFalseTotal
if $args->[0] != $wire_version 0 1 1
28 if $args->[0] != $wire_version;
29 1 ▶ return if $$rdata eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $$rdata eq "" 1 0 1
30 0 goto decode;
31 }
32 11 return rpc_i2d([$op,@$args]);
33 }
34  
35 sub rpc2buf {
36 12 ▶ my ($self,$rpc) = @_;
Subroutine rpc2buf: called CC=1 SCAR=0.0
Pod undocumented
37 12 my ($op,@args) = @{ rpc_d2i($rpc) };
38 12 return pack("SL/a*",$op,Storable::nfreeze(\@args));
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/DualvarMapping.pm ↑ Summary Remote/Sereal.pm »