File Coverage

blib/lib/File/Collector/Processor.pm
Criterion Covered Total %
statement 33 33 100.0
branch 2 2 100.0
condition 2 2 100.0
subroutine 9 9 100.0
pod 3 3 100.0
total 49 49 100.0


line stmt bran cond sub pod time code
1             package File::Collector::Processor ;
2             $File::Collector::Processor::VERSION = '0.036';
3 2     2   2229 use strict;
  2         4  
  2         57  
4 2     2   11 use warnings;
  2         4  
  2         48  
5              
6 2     2   11 use parent 'File::Collector';
  2         4  
  2         13  
7              
8             sub new {
9 22     22 1 50 my ($class, $all, $cselected, $files) = @_;
10              
11 22   100     159 bless { _files => $files || {}, iterator => [], all => $all,
12             selected => '', cselected => $cselected }, $class;
13             }
14              
15             sub next {
16 188     188 1 457 my $s = shift;
17 188 100       403 if (!$s->selected) {
18 18         20 my @files = values %{$s->{_files}};
  18         74  
19 18         45 $s->{iterator} = \@files;
20             }
21 188         270 my $file = shift @{$s->{iterator}};
  188         324  
22 188         278 $s->{selected} = $file;
23 188         261 ${$s->{cselected}} = $file->{full_path};
  188         327  
24 188         466 return $s->{selected};
25             }
26              
27             sub _isa {
28 2     2   12 my $s = shift;
29 2         5 my $file = shift;
30 2         14 return exists $s->{_files}{$file};
31             }
32              
33             sub _add_file {
34 23     23   53 my ($s, $file, $data) = @_;
35 23         82 $s->{_files}{$file} = $data; # add the file's data to processor
36             }
37              
38             sub do {
39 2     2 1 4 my $s = shift;
40 2         19 bless \$s, 'File::Collector::Processor::Do';
41             }
42              
43             {
44             package File::Collector::Processor::Do;
45             $File::Collector::Processor::Do::VERSION = '0.036';
46             sub AUTOLOAD {
47 4     4   9 my $self = shift;
48 4         5 our $AUTOLOAD;
49 4         28 my ($method) = $AUTOLOAD =~ m/::([^:]+)$/;
50 4         13 $$self->$method(@_) while ($$self->next);
51             }
52              
53             }
54              
55             1; # Magic true value
56             # ABSTRACT: Base class for custom File::Collector::Processor classes for processing files classified by a File::Collector class.
57              
58             __END__