lib/App/GitFind/Entry.pm

filter: Statementstmt 48.8% 22 / 45 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 26.9% 7 / 26 Podpod 100% 5 / 5 totaltotal 41.4% 34 / 82 CC 4 SCAR 14.5
CC
4
Cov
43%
BUILD
20.0
__ANON__
2.0
__ANON__
2.0
CRAP 4.3
« lib/App/GitFind/Searcher.pm ↑ Summary lib/App/GitFind/Entry/OnDisk.pm »
1 # App::GitFind::Entry - Abstract base class representing a file or directory
2 package App::GitFind::Entry;
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  
9 1 our $VERSION = '0.000002';
10  
11 1 ▶use parent 'App::GitFind::Class';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # Fields. Not all have values. The default stat() returns are provided
14 # for the convenience of subclasses --- override them in any subclass
15 # that does not provide _lstat.
16 1 ▶use Class::Tiny qw(searchbase);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 # Read-only lazy accessors
19 1 ▶use Class::Tiny::Immutable {
Subroutine BEGIN: called CC=1 SCAR=4.4
20  
21 # The lstat() results for this entry. lstat() rather than stat()
22 # because searches treat links as individual entries rather than
23 # as their referents. (TODO global option?)
24 # This is a lazy initializer so we don't stat() if we don't have to.
25 0 ▶ _lstat => sub { ... },
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 # Returns an arrayref of lstat() results. Must be overriden in
27 # subclasses unless the below uses of _lstat are overridden.
28  
29 0 ▶ dev => sub { $_[0]->_lstat->[0] }, # device number of filesystem
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 0 ▶ ino => sub { $_[0]->_lstat->[1] }, # inode number
Subroutine __ANON__: not called CC=1 SCAR=6.9
31 0 ▶ mode => sub { $_[0]->_lstat->[2] }, # file mode (type and permissions)
Subroutine __ANON__: not called CC=1 SCAR=6.9
32 0 ▶ nlink => sub { $_[0]->_lstat->[3] }, # number of (hard) links to the file
Subroutine __ANON__: not called CC=1 SCAR=6.9
33 0 ▶ uid => sub { $_[0]->_lstat->[4] }, # numeric user ID of file's owner
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 0 ▶ gid => sub { $_[0]->_lstat->[5] }, # numeric group ID of file's owner
Subroutine __ANON__: not called CC=1 SCAR=6.9
35 0 ▶ rdev => sub { $_[0]->_lstat->[6] }, # the device identifier (special files only)
Subroutine __ANON__: not called CC=1 SCAR=6.9
36 0 ▶ size => sub { $_[0]->_lstat->[7] }, # total size of file, in bytes
Subroutine __ANON__: not called CC=1 SCAR=6.9
37 0 ▶ atime => sub { $_[0]->_lstat->[8] }, # last access time in seconds since the epoch
Subroutine __ANON__: not called CC=1 SCAR=6.9
38 0 ▶ mtime => sub { $_[0]->_lstat->[9] }, # last modify time in seconds since the epoch
Subroutine __ANON__: not called CC=1 SCAR=6.9
39 0 ▶ ctime => sub { $_[0]->_lstat->[10] }, # inode change time in seconds since the epoch (*)
Subroutine __ANON__: not called CC=1 SCAR=6.9
40 0 ▶ blksize => sub { $_[0]->_lstat->[11] }, # preferred I/O size in bytes for interacting with the file (may vary from file to file)
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 0 ▶ blocks => sub { $_[0]->_lstat->[12] }, # actual number of system-specific blocks allocated
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 1 };
43  
44 # Docs {{{1
45  
46 =head1 NAME
47  
48 App::GitFind::Entry - Abstract base class representing a file or directory
49  
50 =head1 SYNOPSIS
51  
52 This represents a single file or directory being checked against an expression.
53 Concrete subclasses implement various types of entries.
54  
55 =head1 MEMBERS
56  
57 =head2 searchbase
58  
59 Required L<Path::Class::Dir>. Results will be reported relative to this
60 directory.
61  
62 =head1 METHODS
63  
64 =cut
65  
66 # }}}1
67  
68 =head2 isdir
69  
70 Truthy if it's a directory; falsy otherwise.
71 Must be overriden by subclasses.
72  
73 =cut
74  
75 0 ▶sub isdir { ... }
Subroutine isdir: not called CC=1 SCAR=6.9
Pod documented
76  
77 =head2 name
78  
79 Basename of this entry.
80 Must be overriden by subclasses.
81 TODO May be a string or a Path::Class instance?
82  
83 =cut
84  
85 0 ▶sub name { ... }
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
86  
87 =head2 path
88  
89 Full path of the entry with respect to L</searchbase>.
90 Must be overriden by subclasses.
91 May be a string or a Path::Class instance?
92  
93 =cut
94  
95 0 ▶sub path { ... }
Subroutine path: not called CC=1 SCAR=6.9
Pod documented
96  
97 =head2 prune
98  
99 If this entry represents a directory, mark its children as not to be traversed.
100  
101 If this entry represents a file, no effect.
102  
103 =cut
104  
105 0 ▶sub prune {
Subroutine prune: not called CC=1 SCAR=6.9
Pod documented
106 ...
107 0 }
108  
109 =head2 BUILD
110  
111 Enforce abstractness, and the requirement to provide a C<searchbase>.
112  
113 =cut
114  
115 0 ▶sub BUILD {
Subroutine BUILD: not called CC=4 SCAR=30.0
Pod documented
116 0 my $self = shift;
117 0 ▶ croak "Cannot instantiate abstract base class" if ref $self eq __PACKAGE__;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self eq __PACKAGE__ 0 0 0
118  
119 0 ▶ croak "Usage: @{[ref $self]}->new(-searchbase=>...)"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->searchbase 0 0 0
120 unless $self->searchbase;
121 0 ▶ croak "-searchbase must be a App::GitFind::PathClassMicro::Dir"
Branch: 1 branch
BranchTrueFalseTotal
unless $self->searchbase->DOES("App::GitFind::PathClassMicro::Dir") 0 0 0
122 unless $self->searchbase->DOES('App::GitFind::PathClassMicro::Dir');
123 } #BUILD()
124  
125 1 1;
« lib/App/GitFind/Searcher.pm ↑ Summary lib/App/GitFind/Entry/OnDisk.pm »