Any/SCP/Getter/Finder.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 54 CC 1 SCAR 6.9
CC
1
Cov
0%
_new
2.0
on_open_dir
2.0
on_close_dir
2.0
CRAP 2.0
1 package Net::SSH::Any::SCP::Getter::Finder;
2  
3 use strict;
4 use warnings;
5  
6 use Net::SSH::Any::Util qw(_warn);
7  
8 require Net::SSH::Any::SCP::Getter;
9 our @ISA = qw(Net::SSH::Any::SCP::Getter);
10  
11 sub _new {
12 my $class = shift;
13 my $any = shift;
14 my $opts = shift;
15 $opts->{recursive} = 1;
16 my $g = $class->SUPER::_new($any, $opts, @_);
17 $g->{found} = [];
18 $g->{stack} = [];
19 $g;
20 }
21  
22 sub on_open_dir {
23 my ($g, $action) = @_;
24 push @{$g->{stack}}, $action->{name};
25 1;
26 }
27  
28 sub on_close_dir {
29 my $g = shift;
30 pop @{$g->{stack}};
31 1;
32 }
33  
34 sub on_open_file {
35 my ($g, $action) = @_;
36 my $path = join '/', @{$g->{stack}}, $action->{name};
37 push @{$g->{found}}, $path;
38 0;
39 }
40  
41 sub on_close_file {
42 my ($g, $action, $failed) = @_;
43 not $failed;
44 }
45  
46 sub run {
47 my $g = shift;
48 # remote SCP command return failure when asked to skip some
49 # file or directory, so we ignore the exit code from SUPER::run
50 # if ($g->SUPER::run(@_)) ...
51 $g->SUPER::run(@_);
52 @{$g->{found}}
53 }
54  
55 1;