blib/lib/Net/FTP/Path/Iter/File.pm

filter: Statementstmt 80.9% 34 / 42 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod n/a totaltotal 72.5% 45 / 62 SCAR 19.7
CC
6
Cov
68%
_retrieve_attrs
42.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.2
« blib/lib/Net/FTP/Path/Iter/Dir.pm ↑ Summary blib/lib/Net/FTP/Path/Iter.pm »
1 package Net::FTP::Path::Iter::File;
2  
3 # ABSTRACT: Class representing a File
4  
5 4 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 our $VERSION = '0.06';
10  
11 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 4 ▶use File::Spec::Functions qw[ catfile ];
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 4 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 4 ▶use parent 'Net::FTP::Path::Iter::Entry';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 4 ▶use constant is_file => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 4 ▶use constant is_dir => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 # if an entity doesn't have attributes, it didn't get loaded
26 # from a directory listing. Try to get one.
27 sub _retrieve_attrs {
28  
29 0 ▶ my $self = shift;
Subroutine _retrieve_attrs: not called CC=6 SCAR=37.4
30 0 ▶ return if $self->_has_attrs;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_has_attrs 0 0 0
31  
32 my ( $entry ) = my @entries = grep $self->name eq $_->{name},
33 0 $self->get_entries( $self->parent );
34  
35 0 ▶ croak( "multiple ftp entries for ", $self->path, "\n" )
Branch: 1 branch
BranchTrueFalseTotal
if @entries > 1 0 0 0
36 if @entries > 1;
37  
38 0 ▶ croak( "unable to find attributes for ", $self->path, "\n" )
Branch: 1 branch
BranchTrueFalseTotal
if @entries == 0 0 0 0
39 if @entries == 0;
40  
41 croak( $self->{path}, ": expected file, got $entry->type\n" )
42 0 ▶ unless $entry->{type} eq 'f';
Branch: 1 branch
BranchTrueFalseTotal
unless $entry->{"type"} eq "f" 0 0 0
43  
44 0 $self->$_( $entry->{$_} ) for keys %$entry;
45  
46 0 return;
47 }
48  
49 #
50 # This file is part of Net-FTP-Path-Iter
51 #
52 # This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory.
53 #
54 # This is free software, licensed under:
55 #
56 # The GNU General Public License, Version 3, June 2007
57 #
58  
59 4 1;
60  
61 __END__
« blib/lib/Net/FTP/Path/Iter/Dir.pm ↑ Summary blib/lib/Net/FTP/Path/Iter.pm »