Add the ability to provide a whitelist of repos.
[catagits/Gitalist.git] / lib / Gitalist / Git / CollectionOfRepositories / FromDirectory / WhiteList.pm
1 use MooseX::Declare;
2
3 class Gitalist::Git::CollectionOfRepositories::FromDirectory::WhiteList
4     extends Gitalist::Git::CollectionOfRepositories::FromDirectory {
5     use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
6     use MooseX::Types::Path::Class qw/File Dir/;
7
8     has whitelist => (
9         isa      => File,
10         is       => 'ro',
11         required => 1,
12         coerce   => 1,
13     );
14
15     method _build_repositories {
16         return [
17             map  Gitalist::Git::Repository->new($_),
18             grep -d $_,
19             map  $self->repo_dir->subdir($_), $self->whitelist->slurp(chomp => 1)
20         ];
21     }
22 }
23
24 __END__
25 =head1 NAME
26
27 Gitalist::Git::CollectionOfRepositories::FromDirectory::WhiteList - Model of a repositories listed in a file in a given directory.
28
29 =head1 SYNOPSIS
30
31     my $repo = Gitalist::Git::CollectionOfRepositories::FromDirectory::WhiteList->new(
32       repo_dir  => $Dir,
33       whitelist => 'projects.list',
34     );
35     my $repository_list = $repo->repositories;
36     my $first_repository = $repository_list->[0];
37     my $named_repository = $repo->get_repository('Gitalist');
38
39 =head1 DESCRIPTION
40
41 This class provides a list of Repositories found in the given
42 directory and specified in a given whitelist file.
43
44 =head1 ATTRIBUTES
45
46 =head2 whitelist (C<Path::Class::File>)
47
48 The file containing the available repositories. Each line specifies a
49 different repository within L</repo_dir>.
50
51 =head1 SEE ALSO
52
53 L<Gitalist::Git::CollectionOfRepositories>,
54 L<Gitalist::Git::Repository>, 
55 L<Gitalist::Git::CollectionOfRepositories::FromDirectory>
56
57 =head1 AUTHORS
58
59 See L<Gitalist> for authors.
60
61 =head1 LICENSE
62
63 See L<Gitalist> for the license.
64
65 =cut