Subprocess/Running/Delegate/Handle.pm

filter: Statementstmt 100% 38 / 38 Branchbran 90.0% 9 / 10 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 4 totaltotal 92.6% 63 / 68 CC 7 SCAR 8.8
CC
7
Cov
98%
build_done_delegates
5.0
build_events
2.0
BUILD
2.0
CRAP 2.4
« Subprocess/Job.pm ↑ Summary Subprocess/Role/WithDelegates.pm »
1 package AnyEvent::Subprocess::Running::Delegate::Handle;
2 38 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 38 $AnyEvent::Subprocess::Running::Delegate::Handle::VERSION = '1.102912';
4 }
5 # ABSTRACT: Running part of the Handle delegate
6 38 ▶use AnyEvent::Subprocess::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 38 ▶use AnyEvent::Subprocess::Done::Delegate::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 38 ▶use MooseX::Types::Moose qw(Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 38 ▶use AnyEvent::Subprocess::Types qw(Direction);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 38 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 38 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 37 with 'AnyEvent::Subprocess::Running::Delegate';
15  
16 37 has 'direction' => (
17 is => 'ro',
18 isa => Direction,
19 required => 1,
20 documentation => 'r when parent reads a pipe, w when parent writes to a pipe, rw for a socket',
21 );
22  
23 37 has 'handle' => (
24 is => 'ro',
25 isa => 'AnyEvent::Subprocess::Handle',
26 required => 1,
27 );
28  
29 37 has 'want_leftovers' => (
30 is => 'ro',
31 isa => 'Bool',
32 required => 1,
33 );
34  
35 290 ▶sub build_events {
Subroutine build_events: called CC=2 SCAR=6.9
Pod undocumented
36 290 my ($self, $running) = @_;
37  
38 290 ▶ if( $self->direction eq 'r' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->direction eq "r") 188 102 290
39 188 return $self->name;
40 }
41  
42 102 return;
43 }
44  
45 63 ▶sub build_done_delegates {
Subroutine build_done_delegates: called CC=5 SCAR=16.1
Pod undocumented
46 63 my $self = shift;
47 63 my $h = $self->handle;
48 63 ▶ my $want = $self->want_leftovers ? 1 : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->want_leftovers ? : 1 62 63
49 63 ▶ my ($rbuf, $wbuf) = map { $want && delete $h->{$_} } qw/rbuf wbuf/;
Condition100%3/3
$want && delete $h->{$_}
!ll&&!rl&&r
12411
MC/DC100%2/2
$want && delete $h->{$_}
$want delete $h->{$_}
Truth table100%3/3
A && B
A= $wantB= delete $h->{$_}
ABresult
0X0
100
111
50  
51 63 ▶ return AnyEvent::Subprocess::Done::Delegate::Handle->new(
Branch: 2 branches
BranchTrueFalseTotal
defined $rbuf ? : 0 63 63
defined $wbuf ? : 1 62 63
52 name => $self->name,
53 (defined $rbuf ? (rbuf => $rbuf) : ()),
54 (defined $wbuf ? (wbuf => $wbuf) : ()),
55 );
56 }
57  
58 63 ▶sub completion_hook {}
Subroutine completion_hook: called CC=1 SCAR=0.0
Pod undocumented
59  
60 145 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
61 145 my ($self) = @_;
62  
63 # todo: we should check "rw" also, but there is not a good way to
64 # do this
65 145 ▶ if($self->direction eq 'r'){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->direction eq "r") 94 51 145
66 94 $self->handle->on_finalize(
67 $self->event_sender_for($self->name),
68 );
69 }
70 }
71  
72 37 __PACKAGE__->meta->make_immutable;
73  
74 37 1;
75  
76 __END__
« Subprocess/Job.pm ↑ Summary Subprocess/Role/WithDelegates.pm »