| 1 | package POE::Filter::Hessian; | ||||||||||
| 2 | |||||||||||
| 3 | ## no critic | ||||||||||
| 4 | 2 | our $VERSION = '1.00'; | |||||||||
| 5 | 2 | eval $VERSION; | |||||||||
| 6 | ## use critic | ||||||||||
| 7 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use Hessian::Translator; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use Hessian::Exception; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use YAML; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | #use Smart::Comments; | ||||||||||
| 12 | |||||||||||
| 13 | 2 | with 'MooseX::Clone'; | |||||||||
| 14 | |||||||||||
| 15 | 2 | has 'version' => ( is => 'ro', isa => 'Int', default => 1 ); | |||||||||
| 16 | |||||||||||
| 17 | has 'translator' => ( #{{{ | ||||||||||
| 18 | is => 'ro', | ||||||||||
| 19 | isa => 'Hessian::Translator', | ||||||||||
| 20 | lazy => 1, | ||||||||||
| 21 | 5 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 5 | my $self = shift; | |||||||||
| 23 | 5 | my $version = $self->version(); | |||||||||
| 24 | 5 | my $translator = | |||||||||
| 25 | Hessian::Translator->new( | ||||||||||
| 26 | chunked => 1, | ||||||||||
| 27 | version => $version | ||||||||||
| 28 | ); | ||||||||||
| 29 | 5 | return $translator; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 2 | ); #}}} | |||||||||
| 33 | |||||||||||
| 34 | has 'internal_buffer' => ( | ||||||||||
| 35 | is => 'rw', | ||||||||||
| 36 | isa => 'ArrayRef', | ||||||||||
| 37 | 5 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 5 | []; | |||||||||
| 39 | } | ||||||||||
| 40 | 2 | ); | |||||||||
| 41 | |||||||||||
| 42 | 6 | ▶ | sub get_one_start { #{{{ | ||||||||
|
Subroutine
get_one_start: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 43 | 6 | my ( $self, $array ) = @_; | |||||||||
| 44 | 6 | my $internal_buffer = $self->internal_buffer(); | |||||||||
| 45 | 6 | push @{$internal_buffer}, @{$array}; | |||||||||
| 46 | } #}}} | ||||||||||
| 47 | |||||||||||
| 48 | 21 | ▶ | sub get_one { #{{{ | ||||||||
|
Subroutine
get_one: called CC=5 SCAR=17.8
Pod
documented
| |||||||||||
| 49 | 21 | my $self = shift; | |||||||||
| 50 | 21 | my $translator = $self->translator(); | |||||||||
| 51 | 21 | my $internal_buffer = $self->internal_buffer(); | |||||||||
| 52 | 21 | my $element = shift @{$internal_buffer}; | |||||||||
| 53 | 21 | ▶ | return [] unless $element; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 17 | $translator->append_input_buffer($element); | |||||||||
| 55 | ### get_one | ||||||||||
| 56 | |||||||||||
| 57 | 17 | my $result; | |||||||||
| 58 | 17 | my $return_array = []; | |||||||||
| 59 | 17 | eval { $result = $translator->process_message(); }; | |||||||||
| 60 | 17 | ▶ | if ( my $e = $@ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 0 | my $exception = ref $e; | |||||||||
| 62 | 0 | ▶ | if ($exception) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | ▶ | return [] if Exception::Class->caught('MessageIncomplete::X'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | $e->rethrow(); | |||||||||
| 65 | } | ||||||||||
| 66 | } | ||||||||||
| 67 | 17 | push @{$return_array}, $result;# if $result; | |||||||||
| 68 | 17 | return $return_array; | |||||||||
| 69 | |||||||||||
| 70 | } #}}} | ||||||||||
| 71 | |||||||||||
| 72 | 4 | ▶ | sub get { #{{{ | ||||||||
|
Subroutine
get: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 73 | 4 | my ( $self, $array ) = @_; | |||||||||
| 74 | 4 | $self->get_one_start($array); | |||||||||
| 75 | 4 | my $result = []; | |||||||||
| 76 | 4 | ▶ | while ( my $processed_chunk = $self->get_one() ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 77 | 16 | my $processed_ref = ref $processed_chunk; | |||||||||
| 78 | ### Processed data: Dump($processed_chunk) | ||||||||||
| 79 | ### type: $processed_ref | ||||||||||
| 80 | 16 | ▶ | last unless @{$processed_chunk}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | 12 | push @{$result}, @{$processed_chunk}; | |||||||||
| 82 | } | ||||||||||
| 83 | 4 | return $result; | |||||||||
| 84 | } #}}} | ||||||||||
| 85 | |||||||||||
| 86 | 2 | ▶ | sub put { #{{{ | ||||||||
|
Subroutine
put: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 87 | 2 | my ( $self, $array ) = @_; | |||||||||
| 88 | 2 | my $translator = $self->translator(); | |||||||||
| 89 | 2 | $translator->serializer(); | |||||||||
| 90 | ### serializing: Dump($array) | ||||||||||
| 91 | 2 | my @data = map { $translator->serialize_message($_) } @{$array}; | |||||||||
| 92 | 2 | return \@data; | |||||||||
| 93 | } #}}} | ||||||||||
| 94 | |||||||||||
| 95 | 0 | ▶ | sub get_pending { #{{{ | ||||||||
|
Subroutine
get_pending: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 96 | 0 | my $self = shift; | |||||||||
| 97 | } #}}} | ||||||||||
| 98 | |||||||||||
| 99 | 2 | "one, but we're not the same"; | |||||||||
| 100 | |||||||||||
| 101 | __END__ | ||||||||||