| 1 | 3 | ▶ | use MooseX::Declare; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 2 | |||||||||||||||
| 3 | class Gitalist::Git::CollectionOfRepositories::FromDirectory | ||||||||||||||
| 4 | 3 | ▶ | with Gitalist::Git::CollectionOfRepositories { | ||||||||||||
|
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
| |||||||||||||||
| 5 | 3 | ▶ | use MooseX::Types::Common::String qw/NonEmptySimpleStr/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 3 | ▶ | use MooseX::Types::Path::Class qw/Dir/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 3 | has repo_dir => ( | |||||||||||||
| 9 | isa => Dir, | ||||||||||||||
| 10 | is => 'ro', | ||||||||||||||
| 11 | required => 1, | ||||||||||||||
| 12 | coerce => 1, | ||||||||||||||
| 13 | ); | ||||||||||||||
| 14 | |||||||||||||||
| 15 | 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
| |||||||||||||||
| 16 | |||||||||||||||
| 17 | 3 | ▶ | method BUILD { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 18 | # Make sure repo_dir is an absolute path so that | ||||||||||||||
| 19 | # ->contains() works correctly. | ||||||||||||||
| 20 | 4 | $self->repo_dir->resolve; | |||||||||||||
| 21 | 3 | } | |||||||||||||
| 22 | |||||||||||||||
| 23 | 3 | ▶ | method _get_path_for_repository_name (NonEmptySimpleStr $name) { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_get_path_for_repository_name: called CC=2 SCAR=7.5
Subroutine
__ANON__: called CC=2 SCAR=7.5
| |||||||||||||||
| 24 | 46 | my $path = $self->repo_dir->subdir($name)->resolve; | |||||||||||||
| 25 | 0 | ▶ | die "Directory traversal prohibited" | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 26 | unless $self->repo_dir->contains($path); | ||||||||||||||
| 27 | 0 | return $path; | |||||||||||||
| 28 | 3 | } | |||||||||||||
| 29 | |||||||||||||||
| 30 | 3 | ▶ | method _get_repo_from_name (NonEmptySimpleStr $name) { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||
| 31 | 46 | return Git::Gitalist::Repository->new($self->_get_path_for_repository_name($name)); | |||||||||||||
| 32 | 3 | } | |||||||||||||
| 33 | |||||||||||||||
| 34 | ## Builders | ||||||||||||||
| 35 | 3 | ▶ | method _build_repositories { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||
| 36 | 6 | ▶ | my $dh = $self->repo_dir->open || die "Could not open repo_dir"; | ||||||||||||
|
Condition50%1/2
$self->repo_dir->open || die('Could not open repo_dir')
MC/DC0%0/1
$self->repo_dir->open || die('Could not open repo_dir')
$self->repo_dir->open
Truth table50%1/2
A
A= $self->repo_dir->open
| |||||||||||||||
| 37 | 6 | my @ret; | |||||||||||||
| 38 | 6 | ▶ | while (my $dir_entry = $dh->read) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 39 | # try to get a repository for each entry in repo_dir | ||||||||||||||
| 40 | 42 | eval { | |||||||||||||
| 41 | 42 | my $p = $self->get_repository($dir_entry); | |||||||||||||
| 42 | 12 | push @ret, $p; | |||||||||||||
| 43 | }; | ||||||||||||||
| 44 | } | ||||||||||||||
| 45 | 6 | return \@ret; | |||||||||||||
| 46 | 3 | } | |||||||||||||
| 47 | 3 | ▶ | } # end class | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 48 | |||||||||||||||
| 49 | __END__ | ||||||||||||||