lib/Gitalist/Git/CollectionOfRepositories/FromDirectoryRecursive.pm

filter: Statementstmt 96.6% 58 / 60 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 96.0% 24 / 25 Podpod n/a totaltotal 96.6% 86 / 89 CC 3 SCAR 1.5
CC
3
Cov
97%
_find_repos
2.0
__ANON__
2.0
BEGIN
1.1
CRAP 1.2
« lib/Gitalist/Git/CollectionOfRepositories/Vhost.pm ↑ Summary lib/Gitalist.pm »
1 2 ▶use MooseX::Declare;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 2 ▶class Gitalist::Git::CollectionOfRepositories::FromDirectoryRecursive {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
4 2 ▶ use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶ use MooseX::Types::Path::Class qw/Dir/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶ use Moose::Autobox;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶ use List::Util 'first';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 has repo_dir => (
11 isa => Dir,
12 is => 'ro',
13 required => 1,
14 coerce => 1,
15 );
16  
17 0 ▶ method debug_string { 'repository directory ' . $self->repo_dir }
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=1 SCAR=1.2
18  
19 2 ▶ method BUILD {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BUILD: called CC=1 SCAR=0.0
20 # Make sure repo_dir is an absolute path so that ->contains() works correctly.
21 7 $self->repo_dir->resolve;
22 2 }
23  
24 2 ▶ method _find_repos(Dir $dir) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _find_repos: called CC=2 SCAR=6.9
25 return map {
26 24 ▶ $self->_is_git_repo($_) ? $_ : $self->_find_repos($_)
Branch: 1 branch
BranchTrueFalseTotal
$self->_is_git_repo($_) ? : 25 19 44
27 } grep $_->is_dir, $dir->children;
28 2 }
29  
30 2 ▶ method _get_repo_from_name (NonEmptySimpleStr $name) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=6.9
31 6 ▶ my $repo = first { $_->name eq $name } $self->repositories->flatten
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
my $repo = &first(sub { $_->name eq $name; } , $self->repositories->flatten) or return 4 2 6
32 or return;
33 4 return $repo;
34 2 }
35  
36 2 ▶ method _get_repo_name (NonEmptySimpleStr $name) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _get_repo_name: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
37 # strip off the repo_dir part from a path
38 14 return Path::Class::Dir->new($name)->relative($self->repo_dir)->stringify;
39 2 }
40  
41 ## Builders
42 2 ▶ method _build_repositories {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
43 return [
44 5 map { Git::Gitalist::Repository->new($_, $self->_get_repo_name("$_")) } $self->_find_repos( $self->repo_dir )
45 ];
46 2 }
47 2 with 'Gitalist::Git::CollectionOfRepositories';
48 2 ▶} # end class
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50 __END__
« lib/Gitalist/Git/CollectionOfRepositories/Vhost.pm ↑ Summary lib/Gitalist.pm »