File Coverage

blib/lib/AnyEvent/Open3/Simple/Process.pm
Criterion Covered Total %
statement 17 19 89.4
branch 2 2 100.0
condition n/a
subroutine 8 9 88.8
pod 3 4 75.0
total 30 34 88.2


line stmt bran cond sub pod time code
1             package AnyEvent::Open3::Simple::Process;
2              
3 16     16   70769 use strict;
  16         41  
  16         472  
4 16     16   82 use warnings;
  16         31  
  16         376  
5 16     16   261 use 5.006;
  16         65  
6              
7             # ABSTRACT: Process run using AnyEvent::Open3::Simple
8             our $VERSION = '0.88'; # VERSION
9              
10              
11             sub new
12             {
13 17     17 0 238 my($class, $pid, $stdin) = @_;
14 17         356 bless { pid => $pid, stdin => $stdin, user => '' }, $class;
15             }
16              
17              
18 2     2 1 53 sub pid { shift->{pid} }
19              
20              
21             if($^O eq 'MSWin32')
22             {
23             require Carp;
24             *print = sub { Carp::croak("AnyEvent::Open3::Simple::Process#print is unsupported on this platform") };
25             *say = sub { Carp::croak("AnyEvent::Open3::Simple::Process#say is unsupported on this platform") };
26             }
27             else
28             {
29             *print = sub {
30 0     0   0 my $stdin = shift->{stdin};
31 0         0 print $stdin @_;
32             };
33             *say = sub {
34 2     2   45 my $stdin = shift->{stdin};
35 2         39 print $stdin @_, "\n";
36             };
37             }
38              
39              
40             sub close
41             {
42 14     14 1 254 CORE::close(shift->{stdin});
43             }
44              
45              
46             sub user
47             {
48 3     3 1 813 my($self, $data) = @_;
49 3 100       11 $self->{user} = $data if defined $data;
50 3         11 $self->{user};
51             }
52              
53             1;
54              
55             __END__