Commit | Line | Data |
bd7cb7a1 |
1 | use MooseX::Declare; |
2 | |
cd169152 |
3 | class Gitalist::Git::CollectionOfRepositories::FromListOfDirectories with Gitalist::Git::CollectionOfRepositories { |
bd7cb7a1 |
4 | use MooseX::Types::Common::String qw/NonEmptySimpleStr/; |
5 | use MooseX::Types::Moose qw/ ArrayRef HashRef /; |
6 | use File::Basename qw/basename/; |
7 | use Moose::Autobox; |
8 | |
9 | has repos => ( |
10 | isa => ArrayRef[NonEmptySimpleStr], |
11 | is => 'ro', |
12 | required => 1, |
13 | ); |
271f6b46 |
14 | has _repos_by_name => ( |
bd7cb7a1 |
15 | isa => HashRef[NonEmptySimpleStr], |
16 | is => 'ro', |
17 | lazy_build => 1, |
18 | traits => ['Hash'], |
19 | handles => { |
82bc0f05 |
20 | _get_path_for_repository_name => 'get', |
bd7cb7a1 |
21 | }, |
22 | ); |
23 | |
271f6b46 |
24 | method _build__repos_by_name { |
bd7cb7a1 |
25 | { map { basename($_) => $_ } $self->repos->flatten }; |
26 | } |
27 | |
28 | ## Builders |
82bc0f05 |
29 | method _build_repositories { |
b5ce0e6a |
30 | [ map { $self->get_repository($_) } $self->repos->flatten ]; |
bd7cb7a1 |
31 | } |
32 | } # end class |
33 | |
34 | 1; |
271f6b46 |
35 | |
36 | =head1 NAME |
37 | |
38 | Gitalist::Git::CollectionOfRepositories::FromListOfDirectories - Model of a collection of git repositories |
39 | |
40 | =head1 SYNOPSIS |
41 | |
42 | my $collection = Gitalist::Git::CollectionOfRepositories::FromListOfDirectories->new( repos => [qw/ |
43 | /path/to/repos1 |
44 | /path/to/repos2 |
45 | /] ); |
46 | my $repository_list = $collection->repositories; |
47 | my $first_repository = $repository_list->[0]; |
48 | my $named_repository = $repo->get_repository('Gitalist'); |
49 | |
50 | =head1 DESCRIPTION |
51 | |
52 | This class provides an abstraction for a list of Repository directories. |
53 | |
54 | =head1 ATTRIBUTES |
55 | |
56 | =head2 repos (C<< ArrayRef[NonEmptySimpleStr] >>) |
57 | |
58 | A list of git repository directories |
59 | |
60 | =head1 SEE ALSO |
61 | |
62 | L<Gitalist::Git::CollectionOfRepositories>, L<Gitalist::Git::Repository> |
63 | |
64 | =head1 AUTHORS |
65 | |
66 | See L<Gitalist> for authors. |
67 | |
68 | =head1 LICENSE |
69 | |
70 | See L<Gitalist> for the license. |
71 | |
72 | =cut |