lib/App/GitFind/Searcher/FileSystem.pm

filter: Statementstmt 70.0% 28 / 40 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 81.8% 9 / 11 Podpod 100% 2 / 2 totaltotal 59.0% 39 / 66 CC 6 SCAR 23.7
CC
6
Cov
55%
BUILD
30.0
run
6.0
BEGIN
1.0
CRAP 10.7
« lib/App/GitFind/Class.pm ↑ Summary lib/App/GitFind/Entry/GitIndex.pm »
1 # App::GitFind::Searcher::FileSystem - Search for files on disk
2 package App::GitFind::Searcher::FileSystem;
3  
4 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.000002';
9  
10 1 ▶use parent 'App::GitFind::Searcher';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Class::Tiny qw(repo searchbase);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use App::GitFind::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use App::GitFind::Entry::OnDisk;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use File::Find::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 #use Path::Class;
17 1 ▶use App::GitFind::PathClassMicro;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 0 ▶sub run {
Subroutine run: not called CC=2 SCAR=17.9
Pod documented
42 0 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)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $ffo = $base_iter->next_obj)) 0 0 0
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 0 ▶sub BUILD {
Subroutine BUILD: not called CC=5 SCAR=34.0
Pod documented
65 0 my ($self, $hrArgs) = @_;
66 0 ▶ unless($self->searchbase && $self->repo) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->searchbase and $self->repo) 0 0 0
Condition0%0/3
$self->searchbase and $self->repo
!ll&&!rl&&r
000
MC/DC0%0/2
$self->searchbase and $self->repo
$self->searchbase $self->repo
Truth table0%0/3
A and B
A= $self->searchbaseB= $self->repo
ABresult
0X0
100
111
67 0 require Carp;
68 0 ▶ Carp::croak 'Need a -searchbase' unless $self->searchbase;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->searchbase 0 0 0
69 0 ▶ Carp::croak 'Need a -repo' unless $self->repo;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->repo 0 0 0
70 }
71 } #BUILD()
72  
73 1 1;
74 __END__
« lib/App/GitFind/Class.pm ↑ Summary lib/App/GitFind/Entry/GitIndex.pm »