Interact/Transport/Wrapper/Net_Telnet.pm

filter: Statementstmt 40.7% 22 / 54 Branchbran 0.0% 0 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 4 / 10 Podpod 0.0% 0 / 3 totaltotal 30.5% 26 / 85 CC 10 SCAR 28.2
CC
10
Cov
31%
pump
42.0
_trigger_timeout
12.0
buffer
6.0
CRAP 16.8
« Interact/Transport/SSH.pm ↑ Summary Interact/Transport/Role/StripControlChars.pm »
1 package Net::CLI::Interact::Transport::Wrapper::Net_Telnet;
2 1 $Net::CLI::Interact::Transport::Wrapper::Net_Telnet::VERSION = '2.400001';
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Sub::Quote;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use MooX::Types::MooseLike::Base qw(Str InstanceOf);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 extends 'Net::CLI::Interact::Transport::Wrapper::Base';
8  
9 {
10 1 package # hide from pause
11 Net::CLI::Interact::Transport::Wrapper::Options;
12 1 ▶ use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 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 1 has '_buffer' => (
19 is => 'rw',
20 isa => Str,
21 default => quote_sub(q{''}),
22 );
23  
24 sub buffer {
25 0 ▶ my $self = shift;
Subroutine buffer: not called CC=2 SCAR=17.9
Pod undocumented
26 0 ▶ return $self->_buffer if scalar(@_) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ == 0 0 0 0
27 0 return $self->_buffer(shift);
28 }
29  
30 sub pump {
31 0 ▶ my $self = shift;
Subroutine pump: not called CC=6 SCAR=37.4
Pod undocumented
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 1 has '+timeout' => (
64 trigger => 1,
65 );
66  
67 sub _trigger_timeout {
68 0 ▶ my $self = shift;
Subroutine _trigger_timeout: not called CC=3 SCAR=24.8
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 1 has '+wrapper' => (
78 isa => InstanceOf['Net::Telnet'],
79 );
80  
81 around '_build_wrapper' => sub {
82 0 ▶ my ($orig, $self) = (shift, shift);
Subroutine __ANON__: not called CC=2 SCAR=17.9
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 1 };
93  
94 after 'disconnect' => sub {
95 0 ▶ delete $SIG{CHLD};
Subroutine __ANON__: not called CC=1 SCAR=6.9
96 1 };
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 1 1;
« Interact/Transport/SSH.pm ↑ Summary Interact/Transport/Role/StripControlChars.pm »