Interact/Transport/Role/StripControlChars.pm

filter: Statementstmt 61.9% 13 / 21 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 75.0% 3 / 4 Podpod n/a totaltotal 53.3% 16 / 30 CC 4 SCAR 24.7
CC
4
Cov
52%
__ANON__
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 11.9
« Interact/Transport/Wrapper/Net_Telnet.pm ↑ Summary Interact/Action.pm »
1 package Net::CLI::Interact::Transport::Role::StripControlChars;
2 1 $Net::CLI::Interact::Transport::Role::StripControlChars::VERSION = '2.400001';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 my %ansi_codes = (
9 1 => q/\x1b\[\d+;\d+H/, # code_position_cursor
10 3 => q/\x1b\[\?25h/, #code_show_cursor
11 4 => q/\x1b\x45/, #code_next_line
12 5 => q/\x1b\[2K/, #code_erase_line
13 6 => q/\x1b\[K/, #code_erase_start_line
14 7 => q/\x1b\[\d+;\d+r/, #code_enable_scroll
15 68 => q/\e\[\??\d+(;\d+)*[A-Za-z]/, #VLZ addon from ytti/oxidized
16 );
17  
18 # https://github.com/ollyg/Net-CLI-Interact/issues/22
19 around 'buffer' => sub {
20 0 ▶ my $orig = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
21 0 ▶ my $buffer = ($orig->(@_) || '');
Condition0%0/2
&$orig(@_) || ''
l!l
00
MC/DC0%0/1
&$orig(@_) || ''
&$orig(@_)
Truth table0%0/2
A
A= &$orig(@_)
Aresult
11
00
22  
23 # remove control characters
24 0 $buffer =~ s/[\000-\010\013\014\016-\032\034-\037]//g;
25  
26 # strip ANSI terminal codes
27 0 foreach my $code (sort keys %ansi_codes) {
28 0 my $to = '';
29 0 ▶ $to = "\n" if ($code == 4); # CODE_NEXT_LINE must substitute with '\n'
Branch: 1 branch
BranchTrueFalseTotal
if $code == 4 0 0 0
30 0 $buffer =~ s/$ansi_codes{$code}/$to/g;
31 }
32  
33 0 return $buffer;
34 1 };
35  
36 =pod
37  
38 =cut
39  
40 1 1;
« Interact/Transport/Wrapper/Net_Telnet.pm ↑ Summary Interact/Action.pm »