Interact/Transport/Wrapper/Net_Telnet.pm

filter: Statementstmt 48.1% 26 / 54 Branchbran 11.1% 2 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 6 / 10 Podpod 0.0% 0 / 3 totaltotal 40.0% 34 / 85 CC 10 SCAR 28.0
CC
10
Cov
39%
pump
42.0
_trigger_timeout
12.0
__ANON__
6.0
CRAP 16.4
« Interact/Transport/SSH.pm ↑ Summary Interact/Logger.pm »
1 package Net::CLI::Interact::Transport::Wrapper::Net_Telnet;
2 9 $Net::CLI::Interact::Transport::Wrapper::Net_Telnet::VERSION = '2.400002';
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(Str InstanceOf);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 9 extends 'Net::CLI::Interact::Transport::Wrapper::Base';
8  
9 {
10 9 package # hide from pause
11 Net::CLI::Interact::Transport::Wrapper::Options;
12 9 ▶ use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 9 extends 'Net::CLI::Interact::Transport::Wrapper::Base::Options';
14 }
15  
16 0 ▶sub put { (shift)->wrapper->put( join '', @_ ) }
Subroutine put: not called CC=1 SCAR=6.9
Pod undocumented
17  
18 9 has '_buffer' => (
19 is => 'rw',
20 isa => Str,
21 default => quote_sub(q{''}),
22 );
23  
24 4 ▶sub buffer {
Subroutine buffer: called CC=2 SCAR=6.9
Pod undocumented
25 4 my $self = shift;
26 4 ▶ return $self->_buffer if scalar(@_) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ == 0 2 2 4
27 2 return $self->_buffer(shift);
28 }
29  
30 0 ▶sub pump {
Subroutine pump: not called CC=6 SCAR=37.4
Pod undocumented
31 0 my $self = shift;
32  
33 # try to read all blocks of already available data first
34 0 my $pump_buffer;
35 0 my $available_content = '';
36 0 ▶ while (defined $available_content) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $available_content) 0 0 0
37 0 $available_content = $self->wrapper->get(Errmode => 'return', Timeout => 0);
38 0 ▶ if (defined $available_content) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $available_content) { } 0 0 0
39 0 $self->logger->log('transport', 'debug', 'read one block of data, appending to pump buffer');
40 0 $pump_buffer .= $available_content;
41 }
42 else {
43 0 $self->logger->log('transport', 'debug', 'no block of data available');
44 }
45 }
46  
47 # only try harder if no content was already available
48 0 ▶ if (not defined $pump_buffer) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pump_buffer) 0 0 0
49 # this either returns data or throws an exception because of Net::Telnets default Errmode die
50 0 my $content = $self->wrapper->get(Timeout => $self->timeout);
51 0 ▶ if (defined $content) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $content) { } 0 0 0
52 0 $self->logger->log('transport', 'debug', 'read one block of data while waiting for timeout, appending to pump buffer');
53 0 $pump_buffer .= $content;
54 }
55 else {
56 0 $self->logger->log('transport', 'debug', 'no block of data available waiting for timeout');
57 }
58 }
59 0 ▶ $self->_buffer($self->_buffer . $pump_buffer)
Branch: 1 branch
BranchTrueFalseTotal
if defined $pump_buffer 0 0 0
60 if defined $pump_buffer;
61 }
62  
63 9 has '+timeout' => (
64 trigger => 1,
65 );
66  
67 0 ▶sub _trigger_timeout {
Subroutine _trigger_timeout: not called CC=3 SCAR=24.8
68 0 my $self = shift;
69 0 ▶ if (scalar @_) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_) 0 0 0
70 0 my $timeout = shift;
71 0 ▶ if ($self->connect_ready) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->connect_ready) 0 0 0
72 0 $self->wrapper->timeout($timeout);
73 }
74 }
75 }
76  
77 9 has '+wrapper' => (
78 isa => InstanceOf['Net::Telnet'],
79 );
80  
81 0 ▶around '_build_wrapper' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
82 0 my ($orig, $self) = (shift, shift);
83  
84 0 $self->logger->log('transport', 'notice', 'creating Net::Telnet wrapper for', $self->app);
85 0 $self->$orig(@_);
86  
87 0 ▶ $SIG{CHLD} = 'IGNORE'
Branch: 1 branch
BranchTrueFalseTotal
unless $self->connect_options->reap 0 0 0
88 if not $self->connect_options->reap;
89  
90 0 with 'Net::CLI::Interact::Transport::Role::ConnectCore';
91 0 return $self->connect_core($self->app, $self->runtime_options);
92 9 };
93  
94 2 ▶after 'disconnect' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
95 2 delete $SIG{CHLD};
96 9 };
97  
98 =pod
99  
100 =begin Pod::Coverage
101  
102 buffer
103 connect_ready
104 disconnect
105 pump
106 put
107  
108 =end Pod::Coverage
109  
110 =cut
111  
112 9 1;
« Interact/Transport/SSH.pm ↑ Summary Interact/Logger.pm »