line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Format::JSON::Stream::Writer; |
2
|
|
|
|
|
|
|
$Format::JSON::Stream::Writer::VERSION = '0.0.1'; |
3
|
1
|
|
|
1
|
|
72443
|
use strict; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
16
|
use 5.014; |
|
1
|
|
|
|
|
4
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new |
8
|
|
|
|
|
|
|
{ |
9
|
1
|
|
|
1
|
1
|
342
|
my $class = shift; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
|
|
4
|
my $self = bless {}, $class; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
|
|
4
|
$self->_init(@_); |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
2
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
8
|
use Carp (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
448
|
use JSON::MaybeXS (); |
|
1
|
|
|
|
|
7933
|
|
|
1
|
|
|
|
|
31
|
|
21
|
1
|
|
|
1
|
|
461
|
use Class::XSAccessor accessors => { _out => '_out' }; |
|
1
|
|
|
|
|
2300
|
|
|
1
|
|
|
|
|
6
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _init |
25
|
|
|
|
|
|
|
{ |
26
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
27
|
1
|
|
|
|
|
2
|
my $args = shift; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
6
|
$self->_out( $args->{output} ); |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
4
|
$self->_init_stream(); |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
2
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _print |
37
|
|
|
|
|
|
|
{ |
38
|
5
|
|
|
5
|
|
52
|
my $self = shift; |
39
|
5
|
|
|
|
|
7
|
my $line = shift; |
40
|
|
|
|
|
|
|
|
41
|
5
|
|
|
|
|
24
|
print { $self->_out() } $line, "\n"; |
|
5
|
|
|
|
|
16
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _init_stream |
45
|
|
|
|
|
|
|
{ |
46
|
1
|
|
|
1
|
|
1
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
4
|
$self->_print("# JSON Stream by Shlomif - Version 0.2.0"); |
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
35
|
return; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub put |
54
|
|
|
|
|
|
|
{ |
55
|
2
|
|
|
2
|
1
|
19
|
my $self = shift; |
56
|
2
|
|
|
|
|
3
|
my $token = shift; |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
8
|
$self->_print( JSON::MaybeXS->new( canonical => 1 )->encode($token) ); |
59
|
2
|
|
|
|
|
53
|
$self->_print("--/f"); |
60
|
|
|
|
|
|
|
|
61
|
2
|
|
|
|
|
43
|
return; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub close |
65
|
|
|
|
|
|
|
{ |
66
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
6
|
return close( $self->_out() ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; # End of File::Dir::Dumper |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |