File Coverage

lib/App/GitFind/Searcher/FileSystem.pm
Criterion Covered Total %
statement 26 38 68.4
branch 0 6 0.0
condition 0 3 0.0
subroutine 9 11 81.8
pod 2 2 100.0
total 37 60 61.6


line stmt bran cond sub pod time code
1             # App::GitFind::Searcher::FileSystem - Search for files on disk
2             package App::GitFind::Searcher::FileSystem;
3              
4 1     1   1104 use 5.010;
  1         2  
5 1     1   4 use strict;
  1         1  
  1         17  
6 1     1   4 use warnings;
  1         1  
  1         35  
7              
8             our $VERSION = '0.000002';
9              
10 1     1   5 use parent 'App::GitFind::Searcher';
  1         1  
  1         5  
11 1     1   52 use Class::Tiny qw(repo searchbase);
  1         1  
  1         7  
12              
13 1     1   255 use App::GitFind::Base;
  1         2  
  1         113  
14 1     1   337 use App::GitFind::Entry::OnDisk;
  1         2  
  1         32  
15 1     1   510 use File::Find::Object;
  1         12329  
  1         24  
16             #use Path::Class;
17 1     1   6 use App::GitFind::PathClassMicro;
  1         1  
  1         162  
18              
19             # Docs {{{1
20              
21             =head1 NAME
22              
23             App::GitFind::Searcher::FileSystem - Search for files on disk
24              
25             =head1 SYNOPSIS
26              
27             This is an L<App::GitFind::Searcher> that looks through a file system.
28              
29             =cut
30              
31             # }}}1
32              
33             =head1 FUNCTIONS
34              
35             =head2 run
36              
37             See L<App::GitFind::Searcher/run>.
38              
39             =cut
40              
41             sub run {
42 0     0 1   my ($self, $callback) = @_;
43              
44 0           my $findbase =
45             App::GitFind::PathClassMicro::Dir->new($self->repo->workdir)->relative($self->searchbase);
46 0           my $base_iter = File::Find::Object->new(
47             {followlink=>true}, $findbase
48             );
49              
50 0           while(defined(my $ffo = $base_iter->next_obj)) {
51 0           my $entry = App::GitFind::Entry::OnDisk->new(-obj=>$ffo,
52             -searchbase=>$self->searchbase,
53             -findbase=>$findbase);
54 0           $callback->($entry);
55             # TODO prune and other control
56 0           undef $entry;
57             }
58             } #run()
59              
60             =head2 BUILD
61              
62             =cut
63              
64             sub BUILD {
65 0     0 1   my ($self, $hrArgs) = @_;
66 0 0 0       unless($self->searchbase && $self->repo) {
67 0           require Carp;
68 0 0         Carp::croak 'Need a -searchbase' unless $self->searchbase;
69 0 0         Carp::croak 'Need a -repo' unless $self->repo;
70             }
71             } #BUILD()
72              
73             1;
74             __END__
75             # vi: set fdm=marker: #