| 1 | package Gitalist::Model::CollectionOfRepos; | ||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use MooseX::Types::Moose qw/Undef Maybe ArrayRef Str/; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use MooseX::Types::Common::String qw/NonEmptySimpleStr/; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use MooseX::Types::LoadableClass qw/ LoadableClass /; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use Gitalist::Git::Types qw/ ArrayRefOfDirs Dir DirOrUndef /; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use Moose::Autobox; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use Path::Class qw/ dir /; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||
| 14 | 8 | extends 'Catalyst::Model'; | |||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | has class => ( | |||||||||||||||||||||||||||||||||||||||
| 17 | isa => LoadableClass, | ||||||||||||||||||||||||||||||||||||||||
| 18 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 19 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||
| 20 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||
| 21 | builder => '_build_class', | ||||||||||||||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||
| 24 | 10 | ▶ | sub _build_class { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_class: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||
| 25 | 10 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||
| 27 | 10 | ▶ | if($self->whitelist && -f $self->whitelist) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition66%2/3
$self->whitelist and -f $self->whitelist
MC/DC50%1/2
$self->whitelist and -f $self->whitelist
$self->whitelist
-f $self->whitelist
Truth table66%2/3
A and B
A= $self->whitelistB= -f $self->whitelist
| |||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | return 'Gitalist::Git::CollectionOfRepositories::FromDirectory::WhiteList'; | |||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||
| 30 | elsif($self->search_recursively) { | ||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | return 'Gitalist::Git::CollectionOfRepositories::FromDirectoryRecursive'; | |||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||
| 33 | elsif ($self->repos) { | ||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | return 'Gitalist::Git::CollectionOfRepositories::FromListOfDirectories'; | |||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||
| 36 | elsif ($self->repo_dir) { | ||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | return 'Gitalist::Git::CollectionOfRepositories::FromDirectory'; | |||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||
| 39 | else { | ||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | croak "Don't know where to get repositores from. Try a --repo_dir option, or setting up config"; | |||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||
| 44 | has args => ( | ||||||||||||||||||||||||||||||||||||||||
| 45 | isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||
| 46 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 47 | 16 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 48 | 8 | ); | |||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||
| 50 | 8 | has search_recursively => ( | |||||||||||||||||||||||||||||||||||||||
| 51 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 52 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||
| 53 | default => 0, | ||||||||||||||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||
| 56 | ## XX What is this for? | ||||||||||||||||||||||||||||||||||||||||
| 57 | 8 | has export_ok => ( | |||||||||||||||||||||||||||||||||||||||
| 58 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 59 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||
| 62 | 8 | has whitelist => ( | |||||||||||||||||||||||||||||||||||||||
| 63 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 64 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||
| 65 | predicate => '_has_whitelist', | ||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||
| 68 | # Simple directory of repositories (for list) | ||||||||||||||||||||||||||||||||||||||||
| 69 | 8 | has repo_dir => ( | |||||||||||||||||||||||||||||||||||||||
| 70 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 71 | isa => DirOrUndef, | ||||||||||||||||||||||||||||||||||||||||
| 72 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||
| 73 | builder => '_build_repo_dir', | ||||||||||||||||||||||||||||||||||||||||
| 74 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||
| 77 | # Directory containing list of one or more repositories | ||||||||||||||||||||||||||||||||||||||||
| 78 | 8 | has repos => ( | |||||||||||||||||||||||||||||||||||||||
| 79 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 80 | isa => ArrayRefOfDirs, | ||||||||||||||||||||||||||||||||||||||||
| 81 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||
| 84 | 9 | ▶ | sub _build_repo_dir { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_repo_dir: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 85 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 86 | 9 | return $ENV{GITALIST_REPO_DIR}; | |||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||
| 89 | 16 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 90 | 16 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||
| 92 | 16 | $self->class(); | |||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||
| 94 | 15 | ▶ | if ($self->repo_dir) { $self->repo_dir->resolve } | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||
| 97 | 21 | ▶ | sub COMPONENT { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
COMPONENT: called CC=6 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 98 | 21 | my($class, $ctx, @args) = @_; | |||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||
| 100 | 21 | my $self = $class->new($ctx, @args); | |||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||
| 102 | my %args = ( | ||||||||||||||||||||||||||||||||||||||||
| 103 | export_ok => $self->export_ok || '', | ||||||||||||||||||||||||||||||||||||||||
| 104 | repos => $self->repos, | ||||||||||||||||||||||||||||||||||||||||
| 105 | repo_dir => $self->repo_dir, | ||||||||||||||||||||||||||||||||||||||||
| 106 | $self->_has_whitelist ? (whitelist => $self->whitelist) : (), | ||||||||||||||||||||||||||||||||||||||||
| 107 | 14 | ▶ | %{ $self->args } | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->export_ok || ''
MC/DC0%0/1
$self->export_ok || ''
$self->export_ok
Truth table50%1/2
A
A= $self->export_ok
| |||||||||||||||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||
| 110 | 14 | my $model_class = $self->class; | |||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | $ctx->log->debug("Building $model_class with " . join(", ", map { $_ . " => " . (defined($args{$_}) ? "'" . $args{$_} . "'" : 'undef') } keys %args)) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 113 | if $ctx->debug; | ||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||
| 115 | 14 | my $model = $model_class->new(\%args); | |||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||
| 117 | 14 | ▶ | $ctx->log->debug("Using class '$model_class' " . $model->debug_string) if $ctx->debug; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||
| 119 | 14 | return $model; | |||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||
| 122 | 8 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||
| 124 | __END__ | ||||||||||||||||||||||||||||||||||||||||