Deserializer.pm

filter: Statementstmt 65.9% 31 / 47 Branchbran 31.2% 5 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 77.7% 7 / 9 Podpod 100% 4 / 4 totaltotal 58.0% 47 / 81 CC 10 SCAR 18.0
CC
10
Cov
55%
process_message
12.0
deserialize_message
10.7
__ANON__
3.1
CRAP 6.0
« Translator/Composite.pm ↑ Summary Translator/V2.pm »
1 package Hessian::Deserializer;
2  
3 32 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 32 ▶use YAML;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 ##use Smart::Comments;
6  
7 32 with qw/
8 Hessian::Deserializer::Numeric
9 Hessian::Deserializer::String
10 Hessian::Deserializer::Date
11 Hessian::Deserializer::Binary
12 /;
13  
14 has 'input_handle' => ( #{{{
15 is => 'rw',
16 isa => 'GlobRef',
17 clearer => 'clear_input_handle',
18 lazy => 1,
19 43 ▶ default => sub {#{{{
Subroutine __ANON__: called CC=3 SCAR=11.2
20 43 my $self = shift;
21 43 my $input_handle;
22 43 my $input_string = $self->input_string();
23 43 ▶ if ($input_string) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input_string) 43 0 43
24 43 ▶ open $input_handle, "<", \$input_string
Branch: 1 branch
BranchTrueFalseTotal
open $input_handle, "<", \$input_string or "InputOutput::X"->throw("error", "Unable to read from string input.") 43 0 43
25 or InputOutput::X->throw(
26 error => "Unable to read from string input." );
27 43 return $input_handle;
28 }
29 }
30 32 );
31  
32 57 ▶after 'input_string' => sub { #{{{
Subroutine __ANON__: called CC=1 SCAR=0.0
33 57 my $self = shift;
34  
35 # Get rid of the input file handle if user has given us a new string to
36 # process. input handle should then re-initialize itself the next time it
37 # is called.
38 57 $self->clear_input_handle();
39 32 };
40  
41 64 ▶before qw/deserialize_data deserialize_message/ => sub { #{{{
Subroutine __ANON__: called CC=2 SCAR=6.9
42 64 my ( $self, $input ) = @_;
43 64 my $input_string = $input->{input_string};
44 64 ▶ $self->input_string($input_string) if $input_string;
Branch: 1 branch
BranchTrueFalseTotal
if $input_string 3 61 64
45 32 };
46  
47 52 ▶sub deserialize_data { #{{{
Subroutine deserialize_data: called CC=1 SCAR=0.0
Pod documented
48 52 my ( $self, $args ) = @_;
49 52 my $result = $self->read_hessian_chunk($args);
50 52 return $result;
51 }
52  
53 12 ▶sub deserialize_message { #{{{
Subroutine deserialize_message: called CC=5 SCAR=23.7
Pod documented
54 12 my ( $self, $args ) = @_;
55 12 my $result;
56 12 eval {
57 12 $result =
58 $self->read_message_chunk();
59 };
60 12 ▶ if ( my $e = $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $@) 0 12 12
61 0 print "Got exception ".$e."\n";
62 0 ▶ return if Exception::Class->caught('EndOfInput::X');
Branch: 1 branch
BranchTrueFalseTotal
if "Exception::Class"->caught("EndOfInput::X") 0 0 0
63 0 ▶ $e->rethrow()
Branch: 1 branch
BranchTrueFalseTotal
if $e->isa("Hessian::Exception") or $e->isa("MessageIncomplete::X") 0 0 0
Condition0%0/3
$e->isa("Hessian::Exception") or $e->isa("MessageIncomplete::X")
l!l&&r!l&&!r
000
MC/DC0%0/2
$e->isa("Hessian::Exception") or $e->isa("MessageIncomplete::X")
$e->isa("Hessian::Exception") $e->isa("MessageIncomplete::X")
Truth table0%0/3
A or B
A= $e->isa("Hessian::Exception")B= $e->isa("MessageIncomplete::X")
ABresult
1X1
011
000
64 if $e->isa('Hessian::Exception')
65 or $e->isa('MessageIncomplete::X');
66 }
67 12 return $result;
68 }
69  
70 0 ▶sub next_token { #{{{
Subroutine next_token: not called CC=1 SCAR=6.9
Pod documented
71 0 my $self = shift;
72 0 return $self->deserialize_message();
73 }
74  
75 0 ▶sub process_message { #{{{
Subroutine process_message: not called CC=3 SCAR=24.8
Pod documented
76 0 my $self = shift;
77 0 my $tokens;
78 0 ▶ while ( my $token = $self->deserialize_message()) { #next_token() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $self->deserialize_message) 0 0 0
79 0 ▶ if ( ( ref $token ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $token eq 'HASH') { } 0 0 0
80 0 my @token_keys = keys %{$token};
81 0 @{$tokens}{@token_keys} = @{$token}{@token_keys};
82 }
83 else {
84 0 $tokens = $token;
85 }
86 }
87 0 return $tokens;
88 }
89  
90 32 "one, but we're not the same";
91  
92 __END__
« Translator/Composite.pm ↑ Summary Translator/V2.pm »