Term/ReadLine/Caroline.pm

filter: Statementstmt 30.3% 20 / 66 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 27.2% 6 / 22 Podpod 0.0% 0 / 16 totaltotal 16.0% 26 / 162 CC 21 SCAR 48.4
CC
21
Cov
18%
findConsole
306.0
readline
20.0
addhistory
6.0
CRAP 126.8
« Caroline.pm ↑ Summary
1 package Term::ReadLine::Caroline;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use 5.008_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Term::Encoding qw/term_encoding/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our @ISA = qw(Term::ReadLine::Stub);
9  
10 1 ▶use Caroline;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 0 ▶sub ReadLine { __PACKAGE__ }
Subroutine ReadLine: not called CC=1 SCAR=6.9
Pod undocumented
13  
14 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
15 0 my $class = shift;
16  
17 # Support multi byte characters
18 0 my $encoding = term_encoding();
19 0 binmode *STDIN, ":encoding(${encoding})";
20 0 binmode *STDOUT, ":encoding(${encoding})";
21  
22 0 my $self = bless {
23 caroline => Caroline->new(),
24 IN => *STDIN,
25 OUT => *STDOUT,
26 Attribs => {},
27 }, $class;
28 }
29  
30 0 ▶sub caroline { shift->{caroline} }
Subroutine caroline: not called CC=1 SCAR=6.9
Pod undocumented
31  
32  
33 0 ▶sub readline {
Subroutine readline: not called CC=4 SCAR=30.0
Pod undocumented
34 0 my ( $self, $prompt ) = @_;
35 0 ▶ if (my $cb = $self->{Attribs}->{completion_callback}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cb = $self->{"Attribs"}{"completion_callback"}) 0 0 0
36 0 $self->caroline->completion_callback($cb);
37 }
38 0 my $line = $self->caroline->readline($prompt);
39 0 ▶ $self->caroline->history_add($line) if defined($line) && $line =~ /\S/;
Branch: 1 branch
BranchTrueFalseTotal
if defined $line and $line =~ /\S/ 0 0 0
Condition0%0/3
defined $line and $line =~ /\S/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $line and $line =~ /\S/
defined $line $line =~ /\S/
Truth table0%0/3
A and B
A= defined $lineB= $line =~ /\S/
ABresult
0X0
100
111
40 0 return $line;
41 }
42  
43 0 ▶sub WriteHistory {
Subroutine WriteHistory: not called CC=1 SCAR=6.9
Pod undocumented
44 0 my ($self, $filename) = @_;
45 0 $self->caroline->write_history_file($filename);
46 }
47  
48 0 ▶sub StifleHistory {
Subroutine StifleHistory: not called CC=1 SCAR=6.9
Pod undocumented
49 0 my ($self, $limit) = @_;
50 0 $self->caroline->history_max_len($limit);
51 }
52  
53 0 ▶sub addhistory {
Subroutine addhistory: not called CC=2 SCAR=17.9
Pod undocumented
54 0 my $self = shift;
55 0 for my $entry (@_) {
56 0 $self->caroline->history_add($entry);
57 }
58 }
59 0 ▶sub AddHistory { shift->addhistory(@_) }
Subroutine AddHistory: not called CC=1 SCAR=6.9
Pod undocumented
60 0 ▶sub GetHistory { shift->{history} }
Subroutine GetHistory: not called CC=1 SCAR=6.9
Pod undocumented
61  
62 0 ▶sub IN { shift->{IN} }
Subroutine IN: not called CC=1 SCAR=6.9
Pod undocumented
63 0 ▶sub OUT { shift->{OUT} }
Subroutine OUT: not called CC=1 SCAR=6.9
Pod undocumented
64  
65 0 ▶sub MinLine { undef }
Subroutine MinLine: not called CC=1 SCAR=6.9
Pod undocumented
66  
67  
68  
69 0 ▶sub findConsole {
Subroutine findConsole: not called CC=17 SCAR=57.2
Pod undocumented
70 0 my $console;
71 my $consoleOUT;
72  
73 0 ▶ if (-e "/dev/tty" and $^O ne 'MSWin32') {
Branch: 2 branches
BranchTrueFalseTotal
if (-e '/dev/tty' and $^O ne 'MSWin32') { } 0 0 0
elsif (-e 'con' or $^O eq 'MSWin32') { } 0 0 0
Condition0%0/3
-e "/dev/tty" and $^O ne "MSWin32"
!ll&&!rl&&r
000
MC/DC0%0/2
-e "/dev/tty" and $^O ne "MSWin32"
-e "/dev/tty" $^O ne "MSWin32"
Truth table0%0/3
A and B
A= -e "/dev/tty"B= $^O ne "MSWin32"
ABresult
0X0
100
111
74 0 $console = "/dev/tty";
75 ▶ } elsif (-e "con" or $^O eq 'MSWin32') {
Condition0%0/3
-e "con" or $^O eq "MSWin32"
l!l&&r!l&&!r
000
MC/DC0%0/2
-e "con" or $^O eq "MSWin32"
-e "con" $^O eq "MSWin32"
Truth table0%0/3
A or B
A= -e "con"B= $^O eq "MSWin32"
ABresult
1X1
011
000
76 0 $console = 'CONIN$';
77 0 $consoleOUT = 'CONOUT$';
78 } else {
79 0 $console = "sys\$command";
80 }
81  
82 0 ▶ if (($^O eq 'amigaos') || ($^O eq 'beos') || ($^O eq 'epoc')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($^O eq 'amigaos' or $^O eq 'beos' or $^O eq 'epoc') { } 0 0 0
elsif ($^O eq 'os2') { } 0 0 0
Condition0%0/6
$^O eq "amigaos" or $^O eq "beos" or $^O eq "epoc"
l!l&&r!l&&!r
000
$^O eq "amigaos" or $^O eq "beos"
l!l&&r!l&&!r
000
MC/DC0%0/3
$^O eq "amigaos" or $^O eq "beos" or $^O eq "epoc"
$^O eq "amigaos" $^O eq "beos" $^O eq "epoc"
Truth table0%0/4
A or B or C
A= $^O eq "amigaos"B= $^O eq "beos"C= $^O eq "epoc"
ABCresult
1XX1
01X1
0011
0000
83 0 $console = undef;
84 }
85 elsif ($^O eq 'os2') {
86 0 ▶ if ($DB::emacs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($DB::emacs) { } 0 0 0
87 0 $console = undef;
88 } else {
89 0 $console = "/dev/con";
90 }
91 }
92  
93 0 ▶ $consoleOUT = $console unless defined $consoleOUT;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $consoleOUT 0 0 0
94 0 ▶ $console = "&STDIN" unless defined $console;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $console 0 0 0
95 0 ▶ if ($console eq "/dev/tty" && !open(my $fh, "<", $console)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($console eq "/dev/tty" and not open(my $fh, "<", $console)) 0 0 0
Condition0%0/3
$console eq "/dev/tty" and not open(my $fh, "<", $console)
!ll&&!rl&&r
000
MC/DC0%0/2
$console eq "/dev/tty" and not open(my $fh, "<", $console)
$console eq "/dev/tty" not open(my $fh, "<", $console)
Truth table0%0/3
A and not(B)
A= $console eq "/dev/tty"B= not open(my $fh, "<", $console)
ABresult
0X0
100
111
96 0 $console = "&STDIN";
97 0 undef($consoleOUT);
98 }
99 0 ▶ if (!defined $consoleOUT) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $consoleOUT) 0 0 0
100 0 ▶ $consoleOUT = defined fileno(STDERR) && $^O ne 'MSWin32' ? "&STDERR" : "&STDOUT";
Branch: 1 branch
BranchTrueFalseTotal
defined fileno STDERR && $^O ne 'MSWin32' ? : 0 0 0
Condition0%0/3
defined fileno STDERR and $^O ne "MSWin32"
!ll&&!rl&&r
000
MC/DC0%0/2
defined fileno STDERR and $^O ne "MSWin32"
defined fileno STDERR $^O ne "MSWin32"
Truth table0%0/3
A and B
A= defined fileno STDERRB= $^O ne "MSWin32"
ABresult
0X0
100
111
101 }
102 0 ($console,$consoleOUT);
103 }
104  
105 1 our %Features = (
106 addHistory => 1,
107 getHistory => 1,
108 );
109  
110 0 ▶sub Attribs { shift->{Attribs} }
Subroutine Attribs: not called CC=1 SCAR=6.9
Pod undocumented
111  
112 0 ▶sub Features { \%Features }
Subroutine Features: not called CC=1 SCAR=6.9
Pod undocumented
113  
114 0 ▶sub ornaments {
Subroutine ornaments: not called CC=1 SCAR=0.0
Pod undocumented
115 # NIY
116 }
117  
118 1 1;
119  
120 __END__
« Caroline.pm ↑ Summary