blib/lib/XAS/Lib/Stomp/POE/Filter.pm

filter: Statementstmt 25.0% 8 / 32 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 28.5% 2 / 7 Podpod 100% 5 / 5 totaltotal 30.0% 15 / 50 CC 6 SCAR 18.5
CC
6
Cov
21%
get_one_start
12.0
get_one
6.0
put
6.0
CRAP 6.3
« blib/lib/XAS/Utils.pm ↑ Summary blib/lib/XAS/Lib/Net/POE/Client.pm »
1 package XAS::Lib::Stomp::POE::Filter;
2  
3 1 our $VERSION = '0.01';
4  
5 1 ▶use XAS::Lib::Stomp::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 use XAS::Class
8 1 debug => 0,
9 version => $VERSION,
10 base => 'XAS::Base',
11 accessors => 'filter eol',
12 constants => 'CRLF',
13 constant => {
14 LF => "\n",
15 },
16 1 ▶;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 #use Data::Hexdumper;
19  
20 # ---------------------------------------------------------------------
21 # Public methods
22 # ---------------------------------------------------------------------
23  
24 sub get_one_start {
25 0 ▶ my ($self, $buffers) = @_;
Subroutine get_one_start: not called CC=3 SCAR=24.8
Pod documented
26  
27 0 foreach my $buffer (@$buffers) {
28  
29 0 ▶ if (my $frame = $self->filter->parse($buffer)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $frame = $self->filter->parse($buffer)) 0 0 0
30  
31 0 push(@{$self->{frames}}, $frame);
32  
33 }
34  
35 }
36  
37 }
38  
39 sub get_one {
40 0 ▶ my ($self) = shift;
Subroutine get_one: not called CC=2 SCAR=17.9
Pod documented
41  
42 0 my @ret;
43  
44 0 ▶ if (my $frame = shift(@{$self->{frames}})) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $frame = shift @{$$self{"frames"};}) 0 0 0
45  
46 0 push(@ret, $frame);
47  
48 }
49  
50 0 return \@ret;
51  
52 }
53  
54 sub get_pending {
55 0 ▶ my ($self) = shift;
Subroutine get_pending: not called CC=1 SCAR=6.9
Pod documented
56  
57 0 return $self->filter->get_pending;
58  
59 }
60  
61 sub put {
62 0 ▶ my ($self, $frames) = @_;
Subroutine put: not called CC=2 SCAR=17.9
Pod documented
63  
64 0 my @ret;
65  
66 0 foreach my $frame (@$frames) {
67  
68 0 my $buffer = $frame->as_string;
69  
70 # $self->log->debug(hexdump($buffer));
71 0 push(@ret, $buffer);
72  
73 }
74  
75 0 return \@ret;
76  
77 }
78  
79 # ---------------------------------------------------------------------
80 # Private methods
81 # ---------------------------------------------------------------------
82  
83 sub init {
84 0 ▶ my $class = shift;
Subroutine init: not called CC=2 SCAR=17.9
Pod documented
85  
86 0 my $self = $class->SUPER::init(@_);
87  
88 0 ▶ $self->{eol} = ($self->env->mqlevel > 1.1) ? CRLF : LF;
Branch: 1 branch
BranchTrueFalseTotal
$self->env->mqlevel > 1.1 ? : 0 0 0
89 0 $self->{filter} = XAS::Lib::Stomp::Parser->new();
90  
91 0 return $self;
92  
93 }
94  
95 1 1;
96  
97 __END__
98  
99 =head1 NAME
100  
101 XAS::Lib::Stomp::POE::Filter - An I/O filter for the POE Environment
102  
103 =head1 SYNOPSIS
104  
105 use XAS::Lib::Stomp::POE::Filter;
106  
107 For a server
108  
109 POE::Component::Server::TCP->new(
110 ...
111 Filter => XAS::Lib::Stomp::POE::Filter->new(),
112 ...
113 );
114  
115 For a client
116  
117 POE::Component::Client::TCP->new(
118 ...
119 Filter => XAS::Lib::Stomp::POE::Filter->new(),
120 ...
121 );
122  
123 =head1 DESCRIPTION
124  
125 This module is a filter for the POE environment. It will translate the input
126 buffer into L<XAS::Lib::Stomp::Frame|XAS::Lib::Stomp::Frame> objects and
127 serialize the output buffer from said object.
128  
129 =head1 METHODS
130  
131 =head2 new
132  
133 This method initializes the module.
134  
135 =head2 get_one_start($buffers)
136  
137 This method parses one frame for a buffer and stores it in an internal frames
138 buffer.
139  
140 =over 4
141  
142 =item B<$buffers>
143  
144 A reference to a buffer.
145  
146 =back
147  
148 =head2 get_one
149  
150 This method returns one frame from the internal buffer.
151  
152 =head2 get_pending
153  
154 This method returns the number of pending frames.
155  
156 =head2 put($buffers)
157  
158 This method pulls frames out of the buffer, stringifies them and places them
159 into a internal array. When done it returns that array.
160  
161 =over 4
162  
163 =item B<$buffers>
164  
165 A reference to a buffer of L<XAS::Lib::Stomp::Frame|XAS::Lib::Stomp::Frame>
166 frames.
167  
168 =back
169  
170 =head1 SEE ALSO
171  
172 =over 4
173  
174 =item L<XAS|XAS>
175  
176 =back
177  
178 See the documentation for L<POE::Filter|https://metacpan.org/pod/POE::Filter> for usage.
179  
180 For more information on the STOMP protocol, please refer to: L<http://stomp.github.io/> .
181  
182 =head1 AUTHOR
183  
184 Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt>
185  
186 =head1 COPYRIGHT AND LICENSE
187  
188 Copyright (C) 2014 Kevin L. Esteb
189  
190 This is free software; you can redistribute it and/or modify it under
191 the terms of the Artistic License 2.0. For details, see the full text
192 of the license at http://www.perlfoundation.org/artistic_license_2_0.
193  
194 =cut
« blib/lib/XAS/Utils.pm ↑ Summary blib/lib/XAS/Lib/Net/POE/Client.pm »