Environment/Plugin/Apache2/Apache2/Filter.pm

filter: Statementstmt 54.0% 20 / 37 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 62.5% 5 / 8 Podpod 100% 3 / 3 totaltotal 48.2% 28 / 58 CC 6 SCAR 25.6
CC
6
Cov
43%
new
30.0
read
6.0
print
2.0
CRAP 13.0
« Environment/Plugin/PostgreSQL.pm ↑ Summary Environment/Plugin/Dump.pm »
1 package Test::Environment::Plugin::Apache2::Apache2::Filter;
2  
3 1 our $VERSION = "0.07";
4  
5 1 1;
6  
7 package Apache2::Filter;
8  
9 =head1 NAME
10  
11 Test::Environment::Plugin::Apache2::Apache2::Filter - fake Apache2::Filter for Test::Environment
12  
13 =head1 SYNOPSIS
14  
15 use Test::Environment qw{
16 Apache2
17 };
18
19 my $filter = Apache2::Filter->new(
20 'data' => \$data,
21 );
22
23 is(
24 My::App:Apache2::Filter::handler($filter),
25 Apache2::Const::OK,
26 );
27 is($$filter->r->pnotes('any_news'), 'no');
28  
29 =head1 DESCRIPTION
30  
31 Will populate Apache2::Filter namespace with fake methods that can be used for Apache2::Filter
32 testing.
33  
34 =cut
35  
36 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
38  
39 1 our $VERSION = "0.07";
40  
41 1 ▶use IO::String;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 1 ▶use Carp::Clan ();
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 1 ▶use base 'Class::Accessor::Fast';
Subroutine BEGIN: called CC=1 SCAR=0.0
45 =head1 PROPERTIES
46  
47 ctx
48 data
49 max_buffer_size
50 data_for_next_filter
51 seen_eos
52  
53 =cut
54  
55 1 __PACKAGE__->mk_accessors(qw{
56 ctx
57 data
58 max_buffer_size
59 seen_eos
60 });
61  
62 =head1 METHODS
63  
64 =head2 new()
65  
66 Filter object contructor.
67  
68 =cut
69  
70 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
71 0 my $class = shift;
72 0 my $self = $class->SUPER::new({
73 'data' => '',
74 'request_rec' => {},
75 'max_buffer_size' => 100,
76 @_,
77 });
78
79 0 ▶ if (ref $self->data eq 'SCALAR') {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $self->data eq 'SCALAR') { } 0 0 0
elsif (ref $self->data eq '') { } 0 0 0
elsif (eval { do { $self->data->can('read') } }) { } 0 0 0
80 0 $self->{'data'} = IO::String->new(${$self->data});
81 }
82 elsif (ref $self->data eq '') {
83 0 my $filename = $self->{'data'};
84 0 ▶ open($self->{'data'}, '<', $filename)
Branch: 1 branch
BranchTrueFalseTotal
open $self->{"data"}, "<", $filename or die 'failed to open "' . $filename . '": ' . $! 0 0 0
85 or die 'failed to open "'.$filename.'": '.$!;
86 }
87 0 elsif (eval { $self->data->can('read'); }) {
88 }
89 else {
90 0 Carp::Clan::croak('wrong "data" argument passed');
91 }
92
93 0 return $self;
94 }
95  
96  
97 =head2 read($bufer, $len)
98  
99 Will put $len (or $self->max_bufer_size if smaller) characters from $self->data
100 into the buffer.
101  
102 =cut
103  
104 0 ▶sub read {
Subroutine read: not called CC=2 SCAR=17.9
Pod documented
105 0 my $self = shift;
106  
107 0 my $buffer = \$_[0];
108 0 my $len = $_[1];
109
110 0 ▶ $len = $self->max_buffer_size
Branch: 1 branch
BranchTrueFalseTotal
if $len > $self->max_buffer_size 0 0 0
111 if $len > $self->max_buffer_size;
112
113 0 return read($self->data, $$buffer, $len);
114 }
115  
116  
117 =head2 print(@args)
118  
119 Will append @args to the $self->data_for_next_filter.
120  
121 =cut
122  
123 0 ▶sub print {
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
124 0 my $self = shift;
125  
126 0 $self->{'data_for_next_filter'} .= @_;
127 }
128  
129  
130 1 'man who sold the world';
131  
132 __END__
« Environment/Plugin/PostgreSQL.pm ↑ Summary Environment/Plugin/Dump.pm »