File Coverage

blib/lib/POE/Filter/ParseWords.pm
Criterion Covered Total %
statement 32 43 74.4
branch 2 6 33.3
condition n/a
subroutine 8 11 72.7
pod 6 6 100.0
total 48 66 72.7


line stmt bran cond sub pod time code
1             # Author Chris "BinGOs" Williams
2             #
3             # This module may be used, modified, and distributed under the same
4             # terms as Perl itself. Please see the license that came with your Perl
5             # distribution for details.
6             #
7              
8             package POE::Filter::ParseWords;
9              
10 2     2   93182 use strict;
  2         5  
  2         76  
11 2     2   11 use warnings;
  2         4  
  2         71  
12 2     2   11 use vars qw($VERSION);
  2         9  
  2         114  
13 2     2   11 use base qw(POE::Filter);
  2         3  
  2         2442  
14 2     2   3871 use Text::ParseWords;
  2         3888  
  2         1019  
15              
16             $VERSION = '1.06';
17              
18             sub new {
19 1     1 1 13 my $class = shift;
20 1         4 my %opts = @_;
21 1         7 $opts{lc $_} = delete $opts{$_} for keys %opts;
22 1 50       5 $opts{keep} = 0 unless $opts{keep};
23 1 50       7 $opts{delim} = '\s+' unless $opts{delim};
24 1         3 $opts{BUFFER} = [];
25 1         5 bless \%opts, $class;
26             }
27              
28             sub get {
29 2     2 1 4441 my ($self, $raw) = @_;
30 2         4 my $events = [];
31 2         15 push @$events, [ parse_line( $self->{delim}, $self->{keep}, $_ ) ] for @$raw;
32 2         371 return $events;
33             }
34              
35             sub get_one_start {
36 0     0 1 0 my ($self, $raw) = @_;
37 0         0 push @{ $self->{BUFFER} }, $_ for @$raw;
  0         0  
38             }
39              
40             sub get_one {
41 0     0 1 0 my $self = shift;
42 0         0 my $events = [];
43 0         0 my $event = shift @{ $self->{BUFFER} };
  0         0  
44 0 0       0 push @$events, [ parse_line( $self->{delim}, $self->{keep}, $event ) ] if defined $event;
45 0         0 return $events;
46             }
47              
48             sub put {
49 0     0 1 0 warn "PUT is unimplemented\n";
50 0         0 return;
51             }
52              
53             sub clone {
54 1     1 1 5 my $self = shift;
55 1         3 my $nself = { };
56 1         2 $nself->{$_} = $self->{$_} for keys %{ $self };
  1         13  
57 1         3 $nself->{BUFFER} = [ ];
58 1         4 return bless $nself, ref $self;
59             }
60              
61             1;
62             __END__