File Coverage

blib/lib/Net/FTP/Rule/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::Rule::File;
2              
3             # ABSTRACT: Class representing a File
4              
5 1     1   21 use 5.010;
  1         3  
6 1     1   4 use strict;
  1         3  
  1         21  
7 1     1   5 use warnings;
  1         1  
  1         36  
8              
9             our $VERSION = '0.01'; # TRIAL
10              
11 1     1   11 use strict;
  1         3  
  1         13  
12 1     1   4 use warnings;
  1         2  
  1         19  
13              
14 1     1   4 use Carp;
  1         2  
  1         62  
15              
16 1     1   6 use File::Spec::Functions qw[ catfile ];
  1         2  
  1         35  
17              
18 1     1   5 use namespace::clean;
  1         2  
  1         7  
19              
20 1     1   211 use parent 'Net::FTP::Rule::Entry';
  1         2  
  1         5  
21              
22 1     1   59 use constant is_file => 1;
  1         1  
  1         62  
23 1     1   5 use constant is_dir => 0;
  1         4  
  1         182  
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             my ( $entry ) = my @entries = grep $self->name eq $_->{name},
33 0           $self->get_entries( $self->parent );
34              
35 0 0         croak( "multiple ftp entries for ", $self->path, "\n" )
36             if @entries > 1;
37              
38 0 0         croak( "unable to find attributes for ", $self->path, "\n" )
39             if @entries == 0;
40              
41             croak( $self->{path}, ": expected file, got $entry->type\n" )
42 0 0         unless $entry->{type} eq 'f';
43              
44 0           $self->$_( $entry->{$_} ) for keys %$entry;
45              
46 0           return;
47             }
48              
49             #
50             # This file is part of Net-FTP-Rule
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             1;
60              
61             #pod =head1 DESCRIPTION
62             #pod
63             #pod B is a class representing a file entry. It is a subclass
64             #pod of L; see it for all available methods.
65             #pod
66             #pod
67              
68             __END__