line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Format::JSON::Stream::Reader; |
2
|
|
|
|
|
|
|
$Format::JSON::Stream::Reader::VERSION = '0.0.1'; |
3
|
1
|
|
|
1
|
|
434
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
5
|
1
|
|
|
1
|
|
15
|
use 5.014; |
|
1
|
|
|
|
|
3
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new |
8
|
|
|
|
|
|
|
{ |
9
|
3
|
|
|
3
|
1
|
569
|
my $class = shift; |
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
|
|
8
|
my $self = bless {}, $class; |
12
|
|
|
|
|
|
|
|
13
|
3
|
|
|
|
|
12
|
$self->_init(@_); |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
|
|
7
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
7
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
4
|
use JSON::MaybeXS qw(decode_json); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
67
|
|
21
|
1
|
|
|
1
|
|
6
|
use Class::XSAccessor accessors => { _in => 'in' }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _init |
25
|
|
|
|
|
|
|
{ |
26
|
3
|
|
|
3
|
|
6
|
my $self = shift; |
27
|
3
|
|
|
|
|
5
|
my $args = shift; |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
12
|
$self->_in( $args->{input} ); |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
|
|
9
|
$self->_init_stream(); |
32
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
4
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _readline |
37
|
|
|
|
|
|
|
{ |
38
|
15
|
|
|
15
|
|
22
|
my $self = shift; |
39
|
|
|
|
|
|
|
|
40
|
15
|
|
|
|
|
38
|
return readline( $self->_in() ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _eof |
44
|
|
|
|
|
|
|
{ |
45
|
21
|
|
|
21
|
|
31
|
my $self = shift; |
46
|
|
|
|
|
|
|
|
47
|
21
|
|
|
|
|
66
|
return eof( $self->_in() ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _init_stream |
51
|
|
|
|
|
|
|
{ |
52
|
3
|
|
|
3
|
|
5
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
3
|
50
|
|
|
|
6
|
if ( $self->_readline() ne "# JSON Stream by Shlomif - Version 0.2.0\n" ) |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
|
|
0
|
Carp::confess "No header for JSON stream"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
3
|
|
|
|
|
97
|
return; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub fetch |
63
|
|
|
|
|
|
|
{ |
64
|
9
|
|
|
9
|
1
|
1126
|
my $self = shift; |
65
|
|
|
|
|
|
|
|
66
|
9
|
|
|
|
|
15
|
my $buffer = ""; |
67
|
9
|
|
|
|
|
15
|
my $line; |
68
|
|
|
|
|
|
|
|
69
|
9
|
100
|
|
|
|
17
|
if ( $self->_eof() ) |
70
|
|
|
|
|
|
|
{ |
71
|
3
|
|
|
|
|
37
|
return; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
LINES: |
75
|
6
|
|
|
|
|
55
|
while ( !$self->_eof() ) |
76
|
|
|
|
|
|
|
{ |
77
|
12
|
|
|
|
|
81
|
$line = $self->_readline(); |
78
|
12
|
100
|
|
|
|
289
|
if ( $line eq "--/f\n" ) |
79
|
|
|
|
|
|
|
{ |
80
|
6
|
|
|
|
|
68
|
return decode_json($buffer); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
else |
83
|
|
|
|
|
|
|
{ |
84
|
6
|
|
|
|
|
16
|
$buffer .= $line; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
0
|
|
|
|
|
|
Carp::confess "Error! Reached end of file without record terminator."; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; # End of File::Dir::Dumper |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |