blib/lib/POE/Filter/Bzip2.pm

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