| 1 | package Net::CLI::Interact::Transport::Wrapper::IPC_Run; | ||||||||||
| 2 | 2 | $Net::CLI::Interact::Transport::Wrapper::IPC_Run::VERSION = '2.400002'; | |||||||||
| 3 | 2 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use Sub::Quote; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use MooX::Types::MooseLike::Base qw(ScalarRef InstanceOf); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | extends 'Net::CLI::Interact::Transport::Wrapper::Base'; | |||||||||
| 8 | |||||||||||
| 9 | { | ||||||||||
| 10 | 2 | package # hide from pause | |||||||||
| 11 | Net::CLI::Interact::Transport::Wrapper::Options; | ||||||||||
| 12 | 2 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 2 | extends 'Net::CLI::Interact::Transport::Wrapper::Base::Options'; | |||||||||
| 14 | } | ||||||||||
| 15 | |||||||||||
| 16 | 2 | ▶ | use IPC::Run (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | has '_in' => ( | ||||||||||
| 19 | is => 'rw', | ||||||||||
| 20 | isa => ScalarRef, | ||||||||||
| 21 | ## no critic (ProhibitStringyEval) | ||||||||||
| 22 | 0 | ▶ | default => sub { \eval "''" }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 23 | ## use critic | ||||||||||
| 24 | 2 | ); | |||||||||
| 25 | |||||||||||
| 26 | # writer for the _in slot | ||||||||||
| 27 | 0 | ▶ | sub put { ${ (shift)->_in } .= join '', @_ } | ||||||||
|
Subroutine
put: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 28 | |||||||||||
| 29 | has '_out' => ( | ||||||||||
| 30 | is => 'ro', | ||||||||||
| 31 | isa => ScalarRef, | ||||||||||
| 32 | ## no critic (ProhibitStringyEval) | ||||||||||
| 33 | 0 | ▶ | default => sub { \eval "''" }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 34 | ## use critic | ||||||||||
| 35 | 2 | ); | |||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | sub buffer { | ||||||||
|
Subroutine
buffer: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 38 | 0 | my $self = shift; | |||||||||
| 39 | 0 | ▶ | return ${ $self->_out } if scalar(@_) == 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 0 | return ${ $self->_out } = shift; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | # clearer for the _out slot | ||||||||||
| 44 | has '_err' => ( | ||||||||||
| 45 | is => 'ro', | ||||||||||
| 46 | isa => ScalarRef, | ||||||||||
| 47 | ## no critic (ProhibitStringyEval) | ||||||||||
| 48 | 0 | ▶ | default => sub { \eval "''" }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 49 | ## use critic | ||||||||||
| 50 | 2 | ); | |||||||||
| 51 | |||||||||||
| 52 | 2 | has '_timeout_obj' => ( | |||||||||
| 53 | is => 'lazy', | ||||||||||
| 54 | isa => InstanceOf['IPC::Run::Timer'], | ||||||||||
| 55 | ); | ||||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | sub _build__timeout_obj { return IPC::Run::timeout((shift)->timeout) } | ||||||||
|
Subroutine
_build__timeout_obj: not called CC=1 SCAR=6.9
| |||||||||||
| 58 | |||||||||||
| 59 | 2 | has '+timeout' => ( | |||||||||
| 60 | trigger => quote_sub(q{(shift)->_timeout_obj->start(shift) if scalar @_ > 1}), | ||||||||||
| 61 | ); | ||||||||||
| 62 | |||||||||||
| 63 | 2 | has '+wrapper' => ( | |||||||||
| 64 | isa => InstanceOf['IPC::Run'], | ||||||||||
| 65 | handles => ['pump'], | ||||||||||
| 66 | ); | ||||||||||
| 67 | |||||||||||
| 68 | 0 | ▶ | around '_build_wrapper' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 69 | 0 | my ($orig, $self) = (shift, shift); | |||||||||
| 70 | |||||||||||
| 71 | 0 | $self->logger->log('transport', 'notice', 'booting IPC::Run harness for', $self->app); | |||||||||
| 72 | 0 | $self->$orig(@_); | |||||||||
| 73 | |||||||||||
| 74 | 0 | return IPC::Run::harness( | |||||||||
| 75 | [$self->app, $self->runtime_options], | ||||||||||
| 76 | $self->_in, | ||||||||||
| 77 | $self->_out, | ||||||||||
| 78 | $self->_err, | ||||||||||
| 79 | $self->_timeout_obj, | ||||||||||
| 80 | ); | ||||||||||
| 81 | 2 | }; | |||||||||
| 82 | |||||||||||
| 83 | 0 | ▶ | before 'disconnect' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 84 | 0 | my $self = shift; | |||||||||
| 85 | 0 | $self->wrapper->kill_kill(grace => 1); | |||||||||
| 86 | 2 | }; | |||||||||
| 87 | |||||||||||
| 88 | =pod | ||||||||||
| 89 | |||||||||||
| 90 | =begin Pod::Coverage | ||||||||||
| 91 | |||||||||||
| 92 | buffer | ||||||||||
| 93 | connect_ready | ||||||||||
| 94 | disconnect | ||||||||||
| 95 | put | ||||||||||
| 96 | |||||||||||
| 97 | =end Pod::Coverage | ||||||||||
| 98 | |||||||||||
| 99 | =cut | ||||||||||
| 100 | |||||||||||
| 101 | 2 | 1; | |||||||||