File Coverage

lib/App/GitFind/Entry/GitIndex.pm
Criterion Covered Total %
statement 23 36 63.8
branch 0 8 0.0
condition n/a
subroutine 8 10 80.0
pod 2 2 100.0
total 33 56 58.9


line stmt bran cond sub pod time code
1             # App::GitFind::Entry::GitIndex - App::GitFind::Entry wrapper for a Git::Raw::Index::Entry
2             package App::GitFind::Entry::GitIndex;
3              
4 1     1   1134 use 5.010;
  1         3  
5 1     1   4 use strict;
  1         1  
  1         16  
6 1     1   4 use warnings;
  1         2  
  1         28  
7 1     1   5 use App::GitFind::Base;
  1         3  
  1         116  
8             #use Path::Class;
9 1     1   6 use App::GitFind::PathClassMicro;
  1         1  
  1         40  
10              
11             our $VERSION = '0.000002';
12              
13 1     1   5 use parent 'App::GitFind::Entry';
  1         2  
  1         4  
14              
15             # Fields. Not all have values.
16 1     1   79 use Class::Tiny _qwc <<'EOT';
  1         1  
  1         4  
17             obj # A Git::Raw::Index::Entry instance. Required.
18             repo # A Git::Raw::Repository instance. Required.
19             EOT
20              
21             use Class::Tiny::Immutable {
22             # Lazy cache of an App::GitFind::PathClassMicro::File instance for this path
23 0           '_pathclass' => sub { App::GitFind::PathClassMicro::File->new($_[0]->repo->workdir, $_[0]->obj->path) },
24              
25 0           '_lstat' => sub { [$_[0]->_pathclass->lstat()] },
26              
27 0           isdir => sub { false }, # Git doesn't store dirs, only files.
28 0           name => sub { $_[0]->_pathclass->basename },
29 0           path => sub { $_[0]->_pathclass->relative($_[0]->searchbase) },
30 1     1   478 };
  1         2  
  1         19  
31              
32             # Docs {{{1
33              
34             =head1 NAME
35              
36             # App::GitFind::Entry::GitIndex - App::GitFind::Entry wrapper for a Git::Raw::Index::Entry
37              
38             =head1 SYNOPSIS
39              
40             This represents a single file or directory being checked against an expression.
41             This particular concrete class represents a Git index entry.
42             It requires a L<Git::Raw::Index::Entry> instance. Usage:
43              
44             use Git::Raw 0.83;
45             my $index = Git::Raw::Repository->discover('.')->index;
46             my @entries = $index->entries;
47             my $entry = App::GitFind::Entry::GitIndex->new(-obj => $entries[0]);
48              
49             =head1 METHODS
50              
51             =cut
52              
53             # }}}1
54              
55             =head2 prune
56              
57             TODO
58              
59             =cut
60              
61             sub prune {
62             ...
63 0     0 1   }
64              
65             =head2 BUILD
66              
67             Enforces the requirements on the C<-obj> argument to C<new()>.
68              
69             =cut
70              
71             sub BUILD {
72 0     0 1   my $self = shift;
73 0 0         die "Usage: @{[ref $self]}->new(-obj=>..., -repo=>...)"
  0            
74             unless $self->obj;
75 0 0         die "-obj must be a Git::Raw::Index::Entry"
76             unless $self->obj->DOES('Git::Raw::Index::Entry');
77 0 0         die "Usage: @{[ref $self]}->new(-repo=>..., -obj=>...)"
  0            
78             unless $self->repo;
79 0 0         die "-repo must be a Git::Raw::Repository"
80             unless $self->repo->DOES('Git::Raw::Repository');
81             } #BUILD()
82              
83             1;