File Coverage

blib/lib/Net/FTP/Path/Iter/File.pm
Criterion Covered Total %
statement 32 40 80.0
branch 0 8 0.0
condition n/a
subroutine 11 12 91.6
pod n/a
total 43 60 71.6


line stmt bran cond sub pod time code
1             package Net::FTP::Path::Iter::File;
2              
3             # ABSTRACT: Class representing a File
4              
5 4     4   167246 use 5.010;
  4         12  
6 4     4   20 use strict;
  4         5  
  4         123  
7 4     4   44 use warnings;
  4         24  
  4         365  
8              
9             our $VERSION = '0.07';
10              
11 4     4   18 use strict;
  4         7  
  4         89  
12 4     4   17 use warnings;
  4         6  
  4         142  
13              
14 4     4   20 use Carp;
  4         31  
  4         286  
15              
16 4     4   403 use File::Spec::Functions qw[ catfile ];
  4         774  
  4         182  
17              
18 4     4   417 use namespace::clean;
  4         18319  
  4         29  
19              
20 4     4   1062 use parent 'Net::FTP::Path::Iter::Entry';
  4         9  
  4         26  
21              
22 4     4   296 use constant is_file => 1;
  4         8  
  4         335  
23 4     4   53 use constant is_dir => 0;
  4         8  
  4         1027  
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     0     my $self = shift;
30 0 0         return if $self->_has_attrs;
31              
32 0           my ( $entry ) = my @entries = grep $self->name eq $_->{name}, $self->get_entries( $self->parent );
33              
34 0 0         croak( 'multiple ftp entries for ', $self->path )
35             if @entries > 1;
36              
37 0 0         croak( 'unable to find attributes for ', $self->path )
38             if @entries == 0;
39              
40             croak( $self->{path}, ': expected file, got ', $entry->{type} )
41 0 0         unless $entry->{type} eq 'f';
42              
43 0           $self->$_( $entry->{$_} ) for keys %$entry;
44              
45 0           return;
46             }
47              
48             #
49             # This file is part of Net-FTP-Path-Iter
50             #
51             # This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory.
52             #
53             # This is free software, licensed under:
54             #
55             # The GNU General Public License, Version 3, June 2007
56             #
57              
58             1;
59              
60             __END__