blib/lib/CPAN/FTP/netrc.pm

filter: Statementstmt 13.8% 5 / 36 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 16.6% 1 / 6 Podpod 0.0% 0 / 5 totaltotal 9.0% 6 / 66 CC 11 SCAR 39.8
CC
11
Cov
9%
new
90.0
contains
12.0
hasdefault
2.0
CRAP 53.3
« blib/lib/CPAN/Kwalify.pm ↑ Summary blib/lib/CPAN/Queue.pm »
1 package CPAN::FTP::netrc;
2 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 24 $CPAN::FTP::netrc::VERSION = $CPAN::FTP::netrc::VERSION = "1.01";
5  
6 # package CPAN::FTP::netrc;
7 sub new {
8 0 ▶ my($class) = @_;
Subroutine new: not called CC=9 SCAR=45.0
Pod undocumented
9 0 my $file = File::Spec->catfile($ENV{HOME},".netrc");
10  
11 0 my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
12 $atime,$mtime,$ctime,$blksize,$blocks)
13 = stat($file);
14 0 ▶ $mode ||= 0;
Condition0%0/2
$mode ||= 0
l!l
00
MC/DC0%0/1
$mode ||= 0
$mode
Truth table0%0/2
A
A= $mode
Aresult
11
00
15 0 my $protected = 0;
16  
17 0 my($fh,@machines,$hasdefault);
18 0 $hasdefault = 0;
19 0 ▶ $fh = FileHandle->new or die "Could not create a filehandle";
Branch: 1 branch
BranchTrueFalseTotal
$fh = "FileHandle"->new or die "Could not create a filehandle" 0 0 0
20  
21 0 ▶ if($fh->open($file)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh->open($file)) { } 0 0 0
22 0 $protected = ($mode & 077) == 0;
23 0 local($/) = "";
24 0 ▶ NETRC: while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
25 0 my(@tokens) = split " ", $_;
26 0 ▶ TOKEN: while (@tokens) {
Branch: 1 branch
BranchTrueFalseTotal
if (@tokens) 0 0 0
27 0 my($t) = shift @tokens;
28 0 ▶ if ($t eq "default") {
Branch: 1 branch
BranchTrueFalseTotal
if ($t eq "default") 0 0 0
29 0 $hasdefault++;
30 0 last NETRC;
31 }
32 0 ▶ last TOKEN if $t eq "macdef";
Branch: 1 branch
BranchTrueFalseTotal
if $t eq "macdef" 0 0 0
33 0 ▶ if ($t eq "machine") {
Branch: 1 branch
BranchTrueFalseTotal
if ($t eq "machine") 0 0 0
34 0 push @machines, shift @tokens;
35 }
36 }
37 }
38 } else {
39 0 $file = $hasdefault = $protected = "";
40 }
41  
42 0 bless {
43 'mach' => [@machines],
44 'netrc' => $file,
45 'hasdefault' => $hasdefault,
46 'protected' => $protected,
47 }, $class;
48 }
49  
50 # CPAN::FTP::netrc::hasdefault;
51 0 ▶sub hasdefault { shift->{'hasdefault'} }
Subroutine hasdefault: not called CC=1 SCAR=6.9
Pod undocumented
52 0 ▶sub netrc { shift->{'netrc'} }
Subroutine netrc: not called CC=1 SCAR=6.9
Pod undocumented
53 0 ▶sub protected { shift->{'protected'} }
Subroutine protected: not called CC=1 SCAR=6.9
Pod undocumented
54 sub contains {
55 0 ▶ my($self,$mach) = @_;
Subroutine contains: not called CC=3 SCAR=24.8
Pod undocumented
56 0 for ( @{$self->{'mach'}} ) {
57 0 ▶ return 1 if $_ eq $mach;
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq $mach 0 0 0
58 }
59 0 return 0;
60 }
61  
62 24 1;
« blib/lib/CPAN/Kwalify.pm ↑ Summary blib/lib/CPAN/Queue.pm »