Lumberjack/Frame/JSON.pm

filter: Statementstmt 63.6% 14 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 2 / 4 Podpod n/a totaltotal 61.5% 16 / 26 CC 1 SCAR 4.1
CC
1
Cov
64%
__ANON__
2.0
_read_payload
2.0
BEGIN
1.0
CRAP 1.5
« Lumberjack/Frame/Compressed.pm ↑ Summary Lumberjack.pm »
1 package Net::Lumberjack::Frame::JSON;
2  
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: class for parsing Lumberjack JSON frames
6 1 our $VERSION = '1.01'; # VERSION
7  
8 1 extends 'Net::Lumberjack::Frame';
9  
10 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 has 'type' => ( is => 'ro', isa => 'Str', default => 'J' );
13 1 has 'version' => ( is => 'rw', isa => 'Int', default => 2 );
14  
15 1 has 'seq' => ( is => 'rw', isa => 'Maybe[Int]' );
16 1 has 'data' => ( is => 'rw', isa => 'Maybe[HashRef]' );
17  
18 has 'payload' => (
19 is => 'rw', isa => 'Str', lazy => 1,
20 default => sub {
21 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 0 my $json_str = encode_json( $self->data );
23 0 my $len = length($json_str);
24 0 return pack('NN', $self->seq, $len).$json_str;
25 },
26 1 );
27  
28 sub _read_payload {
29 0 ▶ my ( $self, $fh ) = @_;
Subroutine _read_payload: not called CC=1 SCAR=6.9
30  
31 0 $self->seq( $self->_read_uint32($fh) );
32 0 $self->data( decode_json($self->_read_data($fh)) );
33  
34 0 return;
35 }
36  
37  
38 1 1;
39  
40 __END__
41  
42 =pod
43  
44 =encoding UTF-8
45  
46 =head1 NAME
47  
48 Net::Lumberjack::Frame::JSON - class for parsing Lumberjack JSON frames
49  
50 =head1 VERSION
51  
52 version 1.01
53  
54 =head1 AUTHOR
55  
56 Markus Benning <ich@markusbenning.de>
57  
58 =head1 COPYRIGHT AND LICENSE
59  
60 This software is Copyright (c) 2016 by Markus Benning.
61  
62 This is free software, licensed under:
63  
64 The Apache License, Version 2.0, January 2004
65  
66 =cut
« Lumberjack/Frame/Compressed.pm ↑ Summary Lumberjack.pm »