File Coverage

blib/lib/Plack/Test/AnyEvent/Response.pm
Criterion Covered Total %
statement 26 26 100.0
branch 6 6 100.0
condition n/a
subroutine 7 7 100.0
pod 4 4 100.0
total 43 43 100.0


line stmt bran cond sub pod time code
1             package
2             Plack::Test::AnyEvent::Response;
3              
4 5     5   25 use strict;
  5         13  
  5         180  
5 5     5   23 use warnings;
  5         8  
  5         162  
6 5     5   24 use parent 'HTTP::Response';
  5         7  
  5         28  
7              
8             sub from_psgi {
9 54     54 1 107 my $class = shift;
10              
11 54         241 my $self = HTTP::Response::from_psgi($class, @_);
12 54         10453 bless $self, $class;
13              
14 54         158 return $self;
15             }
16              
17             sub send {
18 21     21 1 4097 my ( $self, @values ) = @_;
19              
20 21         145 $self->{'_cond'}->send(@values);
21             }
22              
23             sub recv {
24 30     30 1 560 my ( $self ) = @_;
25              
26 30         71 my $cond = $self->{'_cond'};
27              
28 30         205 local $SIG{__DIE__} = Plack::Test::AnyEvent->exception_handler($cond);
29              
30 30         164 my $ex = $cond->recv;
31 29 100       3126 if($ex) {
32 3         19 die $ex;
33             }
34             }
35              
36             sub on_content_received {
37 150     150 1 22393 my ( $self, $cb ) = @_;
38              
39 150 100       491 if($cb) {
40 64         115 $self->{'_on_content_received'} = $cb;
41 64 100       337 $cb->($self->content) if $self->{_cond}->ready;
42             }
43 150         9076 return $self->{'_on_content_received'};
44             }
45              
46             1;
47              
48             =pod
49              
50             =begin comment
51              
52             =over
53              
54             =item from_psgi
55              
56             =item send
57              
58             =item recv
59              
60             =item on_content_received
61              
62             =back
63              
64             =end comment
65              
66             =cut