| 1 | # App::GitFind::Entry::OnDisk - a file or directory on disk | ||||||||||
| 2 | package App::GitFind::Entry::OnDisk; | ||||||||||
| 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 | 1 | ▶ | use App::GitFind::Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | #use Path::Class; | ||||||||||
| 9 | 1 | ▶ | use App::GitFind::PathClassMicro; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | our $VERSION = '0.000002'; | |||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | use parent 'App::GitFind::Entry'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | # Fields. Not all have values. | ||||||||||
| 16 | use Class::Tiny | ||||||||||
| 17 | 1 | ▶ | 'obj', # A File::Find::Object::Result instance. Required. | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 1 | 'findbase'; # Where the search started from | |||||||||
| 19 | |||||||||||
| 20 | 1 | ▶ | use Class::Tiny::Immutable { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=3.5
| |||||||||||
| 21 | 0 | ▶ | _lstat => sub { $_[0]->obj->stat_ret }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 22 | |||||||||||
| 23 | # Lazy App::GitFind::PathClassMicro; | ||||||||||
| 24 | 0 | ▶ | _pathclass => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 25 | ($_[0]->isdir ? 'App::GitFind::PathClassMicro::Dir' | ||||||||||
| 26 | : 'App::GitFind::PathClassMicro::File' | ||||||||||
| 27 | )->new( | ||||||||||
| 28 | 0 | ▶ | $_[0]->findbase, @{$_[0]->obj->full_components} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | ) | ||||||||||
| 30 | }, | ||||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | isdir => sub { $_[0]->obj->is_dir }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 33 | 0 | ▶ | name => sub { # basename, whether it's a file or directory | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 34 | 0 | my @x = $_[0]->obj->full_components; | |||||||||
| 35 | 0 | $x[$#x] | |||||||||
| 36 | }, | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | path => sub { $_[0]->_pathclass->relative($_[0]->searchbase) }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 39 | 1 | }; | |||||||||
| 40 | |||||||||||
| 41 | # Docs {{{1 | ||||||||||
| 42 | |||||||||||
| 43 | =head1 NAME | ||||||||||
| 44 | |||||||||||
| 45 | # App::GitFind::Entry::OnDisk - an App::GitFind::Entry representing a file or directory on disk | ||||||||||
| 46 | |||||||||||
| 47 | =head1 SYNOPSIS | ||||||||||
| 48 | |||||||||||
| 49 | This represents a single file or directory being checked against an expression. | ||||||||||
| 50 | This particular concrete class represents a file or directory on disk. | ||||||||||
| 51 | It requires a L<File::Find::Object::Result> instance. Usage: | ||||||||||
| 52 | |||||||||||
| 53 | my $obj = File::Find::Object->new(...)->next_obj; | ||||||||||
| 54 | my $entry = App::GitFind::Entry::OnDisk->new(-obj => $obj); | ||||||||||
| 55 | |||||||||||
| 56 | =head1 METHODS | ||||||||||
| 57 | |||||||||||
| 58 | =cut | ||||||||||
| 59 | |||||||||||
| 60 | # }}}1 | ||||||||||
| 61 | |||||||||||
| 62 | =head2 prune | ||||||||||
| 63 | |||||||||||
| 64 | If this entry represents a directory, mark its children as not to be traversed. | ||||||||||
| 65 | |||||||||||
| 66 | If this entry represents a file, no effect. | ||||||||||
| 67 | |||||||||||
| 68 | =cut | ||||||||||
| 69 | |||||||||||
| 70 | 0 | ▶ | sub prune { | ||||||||
|
Subroutine
prune: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 71 | ... | ||||||||||
| 72 | 0 | } | |||||||||
| 73 | |||||||||||
| 74 | =head2 BUILD | ||||||||||
| 75 | |||||||||||
| 76 | Enforces the requirements on the C<-obj> argument to C<new()>. | ||||||||||
| 77 | |||||||||||
| 78 | =cut | ||||||||||
| 79 | |||||||||||
| 80 | 0 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 81 | 0 | my $self = shift; | |||||||||
| 82 | 0 | ▶ | die "Usage: @{[ref $self]}->new(-obj=>...)" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 83 | unless $self->obj; | ||||||||||
| 84 | 0 | ▶ | die "-obj must be a File::Find::Object::Result" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | unless $self->obj->DOES('File::Find::Object::Result'); | ||||||||||
| 86 | } #BUILD() | ||||||||||
| 87 | |||||||||||
| 88 | 1 | 1; | |||||||||