blib/lib/POE/Filter/LZW.pm

filter: Statementstmt 88.3% 53 / 60 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 100% 7 / 7 totaltotal 84.6% 77 / 91 CC 12 SCAR 9.9
CC
12
Cov
82%
level
6.0
get
3.1
put
3.1
CRAP 2.7
↑ Summary
1 package POE::Filter::LZW;
2 2 $POE::Filter::LZW::VERSION = '1.74';
3 #ABSTRACT: A POE filter wrapped around Compress::LZW
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Compress::LZW qw(compress decompress);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use base qw(POE::Filter);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
12 2 my $type = shift;
13 2 ▶ croak "$type requires an even number of parameters" if @_ % 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ % 2 0 2 2
14 2 my $buffer = { @_ };
15 2 $buffer->{ lc $_ } = delete $buffer->{ $_ } for keys %{ $buffer };
16 2 $buffer->{BUFFER} = [];
17 2 return bless $buffer, $type;
18 }
19  
20 0 ▶sub level {
Subroutine level: not called CC=2 SCAR=17.9
Pod documented
21 0 my $self = shift;
22 0 my $level = shift;
23 0 ▶ $self->{level} = $level if defined $level;
Branch: 1 branch
BranchTrueFalseTotal
if defined $level 0 0 0
24 0 return $self->{level};
25 }
26  
27 2 ▶sub get {
Subroutine get: called CC=3 SCAR=11.3
Pod documented
28 2 my ($self, $raw_lines) = @_;
29 2 my $events = [];
30  
31 2 foreach my $raw_line (@$raw_lines) {
32 2 ▶ if ( my $line = decompress( $raw_line ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $line = decompress($raw_line)) { } 2 0 2
33 2 push @$events, $line;
34 }
35 else {
36 0 warn "Couldn\'t decompress input\n";
37 }
38 }
39 2 return $events;
40 }
41  
42 1 ▶sub get_one_start {
Subroutine get_one_start: called CC=2 SCAR=6.9
Pod documented
43 1 my ($self, $raw_lines) = @_;
44 1 push @{ $self->{BUFFER} }, $_ for @{ $raw_lines };
45 }
46  
47 4 ▶sub get_one {
Subroutine get_one: called CC=3 SCAR=11.1
Pod documented
48 4 my $self = shift;
49 4 my $events = [];
50  
51 4 ▶ if ( my $raw_line = shift @{ $self->{BUFFER} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $raw_line = shift @{$$self{"BUFFER"};}) 3 1 4
52 3 ▶ if ( my $line = decompress( $raw_line ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $line = decompress($raw_line)) { } 3 0 3
53 3 push @$events, $line;
54 }
55 else {
56 0 warn "Couldn\'t decompress input\n";
57 }
58 }
59 4 return $events;
60 }
61  
62 3 ▶sub put {
Subroutine put: called CC=3 SCAR=11.3
Pod documented
63 3 my ($self, $events) = @_;
64 3 my $raw_lines = [];
65  
66 3 foreach my $event (@$events) {
67 5 ▶ if ( my $line = compress( $event, $self->{level} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $line = compress($event, $self->{'level'})) { } 5 0 5
68 5 push @$raw_lines, $line;
69 }
70 else {
71 0 warn "Couldn\'t compress output\n";
72 }
73 }
74 3 return $raw_lines;
75 }
76  
77 1 ▶sub clone {
Subroutine clone: called CC=2 SCAR=6.9
Pod documented
78 1 my $self = shift;
79 1 my $nself = { };
80 1 $nself->{$_} = $self->{$_} for keys %{ $self };
81 1 $nself->{BUFFER} = [ ];
82 1 return bless $nself, ref $self;
83 }
84  
85 2 qq[Cmprss me];
86  
87 __END__
↑ Summary