blib/lib/Net/SSH/Perl/Util/Term.pm

filter: Statementstmt 25.9% 7 / 27 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 2 / 5 Podpod n/a totaltotal 22.5% 9 / 40 SCAR 28.8
CC
5
Cov
20%
_prompt
20.0
_read_yes_or_no
6.0
_read_passphrase
2.0
CRAP 17.8
« blib/lib/Net/SSH/Perl/Cipher/DES3.pm ↑ Summary blib/lib/Net/SSH/Perl/Util/SSH1MP.pm »
1 package Net::SSH::Perl::Util::Term;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 sub _prompt {
6 0 ▶ my($prompt, $def, $echo) = @_;
Subroutine _prompt: not called CC=4 SCAR=30.0
7 0 ▶ unless ($echo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($echo) { } 0 0 0
8 0 return _read_passphrase($prompt);
9 }
10 else {
11 0 ▶ print $prompt . ($def ? "[$def] " : "");
Branch: 1 branch
BranchTrueFalseTotal
$def ? : 0 0 0
12 0 chomp(my $ans = <STDIN>);
13 0 ▶ return $ans ? $ans : $def;
Branch: 1 branch
BranchTrueFalseTotal
$ans ? : 0 0 0
14 }
15 }
16  
17 sub _read_passphrase {
18 0 ▶ my($prompt) = @_;
Subroutine _read_passphrase: not called CC=1 SCAR=6.9
19 0 print $prompt;
20 0 require Term::ReadKey;
21 0 Term::ReadKey->import;
22 0 ReadMode('noecho');
23 0 chomp(my $pwd = ReadLine(0));
24 0 ReadMode('restore');
25 0 print "\n";
26 0 $pwd;
27 }
28  
29 sub _read_yes_or_no {
30 0 ▶ my($prompt, $def) = @_;
Subroutine _read_yes_or_no: not called CC=2 SCAR=17.9
31 0 print $prompt, " [$def] ";
32 0 chomp(my $ans = <STDIN>);
33 0 ▶ $ans = $def unless $ans;
Branch: 1 branch
BranchTrueFalseTotal
unless $ans 0 0 0
34 0 $ans =~ /^y/i;
35 }
36  
37 5 1;
« blib/lib/Net/SSH/Perl/Cipher/DES3.pm ↑ Summary blib/lib/Net/SSH/Perl/Util/SSH1MP.pm »