VCI/Abstract/FileContainer.pm

filter: Statementstmt 34.4% 10 / 29 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 2 / 5 Podpod n/a totaltotal 33.3% 12 / 36 CC 3 SCAR 17.9
CC
3
Cov
32%
_get_histories
12.0
_build_contents_history
2.0
_build_contents_history_recursive
2.0
CRAP 6.0
« VCI/VCS/Bzr/History.pm ↑ Summary VCI/VCS/Git/Project.pm »
1 package VCI::Abstract::FileContainer;
2 4 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 4 ▶use VCI::Abstract::Committable; # This makes the Type Constraint work
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # Unfortunately we can't currently enforce this, because Moose throws an
7 # error about attribute conflicts for a Directory, which is both a Committable
8 # and a FileContainer.
9 #with 'VCI::Abstract::ProjectItem';
10  
11 4 has 'contents' => (is => 'ro', isa => 'ArrayRef[VCI::Abstract::Committable]',
12 lazy_build => 1);
13 4 has 'contents_history' => (is => 'ro', isa => 'VCI::Abstract::History',
14 lazy_build => 1);
15 4 has contents_history_recursive
16 => (is => 'ro', isa => 'VCI::Abstract::History', lazy_build => 1);
17  
18 # Unfortunately Moose is a little dumb about Roles sometimes, and requires
19 # our *abstract* classes to implement these, instead of our subclasses. So
20 # we can't really require them.
21 #requires 'build_contents';
22  
23 0 ▶sub _build_contents_history {
Subroutine _build_contents_history: not called CC=1 SCAR=6.9
24 0 my $self = shift;
25 0 my @histories = map {$_->history} @{$self->contents};
26 0 return $self->history_class->union(
27 histories => \@histories, project => $self->project);
28 }
29  
30 0 ▶sub _build_contents_history_recursive {
Subroutine _build_contents_history_recursive: not called CC=1 SCAR=6.9
31 0 my $self = shift;
32 0 my @histories;
33 0 push(@histories, $self->contents_history);
34 0 push(@histories, @{ _get_histories($self->contents) });
35 0 return $self->history_class->union(
36 histories => \@histories, project => $self->project);
37 }
38  
39 # Helper for build_contents_history_recursive.
40 0 ▶sub _get_histories {
Subroutine _get_histories: not called CC=3 SCAR=24.8
41 0 my ($items) = @_;
42 0 my @histories;
43 0 foreach my $item (@$items) {
44 0 ▶ if ($item->does('VCI::Abstract::FileContainer')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item->does("VCI::Abstract::FileContainer")) 0 0 0
45 0 push(@histories, @{ _get_histories($item->contents) });
46 0 push(@histories, $item->contents_history);
47 }
48 }
49 0 return \@histories;
50 }
51  
52 4 1;
53  
54 __END__
« VCI/VCS/Bzr/History.pm ↑ Summary VCI/VCS/Git/Project.pm »