| 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
MC/DC0%0/1
$mode ||= 0
$mode
Truth table0%0/2
A
A= $mode
| |||||||||||||
| 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
| |||||||||||||
| 20 | |||||||||||||
| 21 | 0 | ▶ | if($fh->open($file)) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 22 | 0 | $protected = ($mode & 077) == 0; | |||||||||||
| 23 | 0 | local($/) = ""; | |||||||||||
| 24 | 0 | ▶ | NETRC: while (<$fh>) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | 0 | my(@tokens) = split " ", $_; | |||||||||||
| 26 | 0 | ▶ | TOKEN: while (@tokens) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 27 | 0 | my($t) = shift @tokens; | |||||||||||
| 28 | 0 | ▶ | if ($t eq "default") { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 29 | 0 | $hasdefault++; | |||||||||||
| 30 | 0 | last NETRC; | |||||||||||
| 31 | } | ||||||||||||
| 32 | 0 | ▶ | last TOKEN if $t eq "macdef"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 33 | 0 | ▶ | if ($t eq "machine") { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 58 | } | ||||||||||||
| 59 | 0 | return 0; | |||||||||||
| 60 | } | ||||||||||||
| 61 | |||||||||||||
| 62 | 24 | 1; | |||||||||||