| 1 | package File::Dir::Dumper::Stream::JSON::Writer; | ||
| 2 | 4 | $File::Dir::Dumper::Stream::JSON::Writer::VERSION = '0.6.4'; | |
| 3 | 4 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 4 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 4 | ▶ | use 5.012; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 4 | ▶ | use parent 'File::Dir::Dumper::Base'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 4 | ▶ | use Carp (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | 4 | ▶ | use JSON::MaybeXS (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 4 | ▶ | use Class::XSAccessor accessors => { _out => '_out' }; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | |||
| 15 | |||
| 16 | sub _init | ||
| 17 | { | ||
| 18 | 2 | ▶ | my $self = shift; |
|
Subroutine
_init: called CC=1 SCAR=0.0
| |||
| 19 | 2 | my $args = shift; | |
| 20 | |||
| 21 | 2 | $self->_out( $args->{output} ); | |
| 22 | |||
| 23 | 2 | $self->_init_stream(); | |
| 24 | |||
| 25 | 2 | return; | |
| 26 | } | ||
| 27 | |||
| 28 | sub _print | ||
| 29 | { | ||
| 30 | 28 | ▶ | my $self = shift; |
|
Subroutine
_print: called CC=1 SCAR=0.0
| |||
| 31 | 28 | my $line = shift; | |
| 32 | |||
| 33 | 28 | print { $self->_out() } $line, "\n"; | |
| 34 | } | ||
| 35 | |||
| 36 | sub _init_stream | ||
| 37 | { | ||
| 38 | 2 | ▶ | my $self = shift; |
|
Subroutine
_init_stream: called CC=1 SCAR=0.0
| |||
| 39 | |||
| 40 | 2 | $self->_print("# JSON Stream by Shlomif - Version 0.2.0"); | |
| 41 | |||
| 42 | 2 | return; | |
| 43 | } | ||
| 44 | |||
| 45 | sub put | ||
| 46 | { | ||
| 47 | 13 | ▶ | my $self = shift; |
|
Subroutine
put: called CC=1 SCAR=0.0
Pod
documented
| |||
| 48 | 13 | my $token = shift; | |
| 49 | |||
| 50 | 13 | $self->_print( JSON::MaybeXS->new( canonical => 1 )->encode($token) ); | |
| 51 | 13 | $self->_print("--/f"); | |
| 52 | |||
| 53 | 13 | return; | |
| 54 | } | ||
| 55 | |||
| 56 | sub close | ||
| 57 | { | ||
| 58 | 2 | ▶ | my $self = shift; |
|
Subroutine
close: called CC=1 SCAR=0.0
Pod
documented
| |||
| 59 | |||
| 60 | 2 | return close( $self->_out() ); | |
| 61 | } | ||
| 62 | |||
| 63 | |||
| 64 | 4 | 1; # End of File::Dir::Dumper | |
| 65 | |||
| 66 | __END__ | ||