Lumberjack/Frame/Data.pm

filter: Statementstmt 30.3% 10 / 33 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 33.3% 1 / 3 Podpod n/a totaltotal 24.4% 11 / 45 CC 5 SCAR 25.9
CC
5
Cov
25%
__ANON__
20.0
_read_payload
6.0
BEGIN
1.0
CRAP 13.3
« Lumberjack/Writer.pm ↑ Summary Lumberjack/Frame.pm »
1 package Net::Lumberjack::Frame::Data;
2  
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: class for parsing Lumberjack data frames
6 1 our $VERSION = '1.01'; # VERSION
7  
8 1 extends 'Net::Lumberjack::Frame';
9  
10 1 has 'type' => ( is => 'ro', isa => 'Str', default => 'D' );
11  
12 1 has 'seq' => ( is => 'rw', isa => 'Maybe[Int]' );
13 1 has 'data' => ( is => 'rw', isa => 'Maybe[HashRef]' );
14  
15 has 'payload' => (
16 is => 'rw', isa => 'Str', lazy => 1,
17 default => sub {
18 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
19 0 my $pairs = scalar keys %{$self->data};
20 0 my $data = '';
21 0 foreach my $key ( keys %{$self->data} ) {
22 # skip if emtpy or not a scalar
23 0 ▶ if( ! defined $self->data->{$key}
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->data->{$key} or ref $self->data->{$key}) 0 0 0
Condition0%0/3
not defined $self->data->{$key} or ref $self->data->{$key}
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $self->data->{$key} or ref $self->data->{$key}
not defined $self->data->{$key} ref $self->data->{$key}
Truth table0%0/3
not(A) or B
A= not defined $self->data->{$key}B= ref $self->data->{$key}
ABresult
1X1
011
000
24 || ref($self->data->{$key}) ) {
25 0 next;
26 }
27 0 my $keylen = length($key);
28 0 $data .= pack('N', $keylen).$key;
29 0 my $valuelen = length( $self->data->{$key} );
30 0 $data .= pack('N', $valuelen).$self->data->{$key};
31 }
32 0 return pack('NN', $self->seq, $pairs).$data;
33 },
34 1 );
35  
36 sub _read_payload {
37 0 ▶ my ( $self, $fh ) = @_;
Subroutine _read_payload: not called CC=2 SCAR=17.9
38 0 my $data = {};
39  
40 0 $self->seq( $self->_read_uint32($fh) );
41 0 my $pairs = $self->_read_uint32($fh);
42 0 ▶ for( my $i = 0 ; $i < $pairs ; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $pairs) 0 0 0
43 0 my $key = $self->_read_data($fh);
44 0 my $value = $self->_read_data($fh);
45 0 $data->{$key} = $value;
46 }
47 0 $self->data( $data );
48 0 return;
49 }
50  
51  
52 1 1;
53  
54 __END__
55  
56 =pod
57  
58 =encoding UTF-8
59  
60 =head1 NAME
61  
62 Net::Lumberjack::Frame::Data - class for parsing Lumberjack data frames
63  
64 =head1 VERSION
65  
66 version 1.01
67  
68 =head1 AUTHOR
69  
70 Markus Benning <ich@markusbenning.de>
71  
72 =head1 COPYRIGHT AND LICENSE
73  
74 This software is Copyright (c) 2016 by Markus Benning.
75  
76 This is free software, licensed under:
77  
78 The Apache License, Version 2.0, January 2004
79  
80 =cut
« Lumberjack/Writer.pm ↑ Summary Lumberjack/Frame.pm »