| 1 | package Net::CLI::Interact::Transport::Wrapper::IPC_Run; | ||
| 2 | $Net::CLI::Interact::Transport::Wrapper::IPC_Run::VERSION = '2.400001'; | ||
| 3 | 9 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 9 | ▶ | use Sub::Quote; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 9 | ▶ | use MooX::Types::MooseLike::Base qw(ScalarRef InstanceOf); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | extends 'Net::CLI::Interact::Transport::Wrapper::Base'; | ||
| 8 | |||
| 9 | { | ||
| 10 | package # hide from pause | ||
| 11 | Net::CLI::Interact::Transport::Wrapper::Options; | ||
| 12 | 9 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | extends 'Net::CLI::Interact::Transport::Wrapper::Base::Options'; | ||
| 14 | } | ||
| 15 | |||
| 16 | 9 | ▶ | use IPC::Run (); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 17 | |||
| 18 | has '_in' => ( | ||
| 19 | is => 'rw', | ||
| 20 | isa => ScalarRef, | ||
| 21 | ## no critic (ProhibitStringyEval) | ||
| 22 | default => sub { \eval "''" }, | ||
| 23 | ## use critic | ||
| 24 | ); | ||
| 25 | |||
| 26 | # writer for the _in slot | ||
| 27 | sub put { ${ (shift)->_in } .= join '', @_ } | ||
| 28 | |||
| 29 | has '_out' => ( | ||
| 30 | is => 'ro', | ||
| 31 | isa => ScalarRef, | ||
| 32 | ## no critic (ProhibitStringyEval) | ||
| 33 | default => sub { \eval "''" }, | ||
| 34 | ## use critic | ||
| 35 | ); | ||
| 36 | |||
| 37 | sub buffer { | ||
| 38 | my $self = shift; | ||
| 39 | return ${ $self->_out } if scalar(@_) == 0; | ||
| 40 | 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 | default => sub { \eval "''" }, | ||
| 49 | ## use critic | ||
| 50 | ); | ||
| 51 | |||
| 52 | has '_timeout_obj' => ( | ||
| 53 | is => 'lazy', | ||
| 54 | isa => InstanceOf['IPC::Run::Timer'], | ||
| 55 | ); | ||
| 56 | |||
| 57 | sub _build__timeout_obj { return IPC::Run::timeout((shift)->timeout) } | ||
| 58 | |||
| 59 | has '+timeout' => ( | ||
| 60 | trigger => quote_sub(q{(shift)->_timeout_obj->start(shift) if scalar @_ > 1}), | ||
| 61 | ); | ||
| 62 | |||
| 63 | has '+wrapper' => ( | ||
| 64 | isa => InstanceOf['IPC::Run'], | ||
| 65 | handles => ['pump'], | ||
| 66 | ); | ||
| 67 | |||
| 68 | around '_build_wrapper' => sub { | ||
| 69 | my ($orig, $self) = (shift, shift); | ||
| 70 | |||
| 71 | $self->logger->log('transport', 'notice', 'booting IPC::Run harness for', $self->app); | ||
| 72 | $self->$orig(@_); | ||
| 73 | |||
| 74 | 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 | }; | ||
| 82 | |||
| 83 | before 'disconnect' => sub { | ||
| 84 | my $self = shift; | ||
| 85 | $self->wrapper->kill_kill(grace => 1); | ||
| 86 | }; | ||
| 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 | 1; | ||