3 class Gitalist::Git::CollectionOfRepositories::FromDirectory
4 with Gitalist::Git::CollectionOfRepositories {
5 use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
6 use MooseX::Types::Path::Class qw/Dir/;
16 # Make sure repo_dir is an absolute path so that
17 # ->contains() works correctly.
18 $self->repo_dir->resolve;
21 method _get_path_for_project_name (NonEmptySimpleStr $name) {
22 my $path = $self->repo_dir->subdir($name)->resolve;
23 die "Directory traversal prohibited"
24 unless $self->repo_dir->contains($path);
29 method _build_projects {
30 my $dh = $self->repo_dir->open || die "Could not open repo_dir";
32 while (my $dir_entry = $dh->read) {
33 # try to get a project for each entry in repo_dir
35 my $p = $self->get_project($dir_entry);
47 Gitalist::Git::CollectionOfRepositories::FromDirectory - Model of a repository directory
51 my $repo = Gitalist::Git::CollectionOfRepositories::FromDirectory->new( repo_dir => $Dir );
52 my $project_list = $repo->projects;
53 my $first_project = $project_list->[0];
54 my $named_project = $repo->get_project('Gitalist');
58 This class provides a list of Repositories found in the given directory.
62 =head2 repo_dir (C<Path::Class::Dir>)
64 The filesystem root of the C<Repo>.
68 An array of all L<Gitalist::Git::Repository>s found in C<repo_dir>.
74 =head2 get_project (Str $name)
76 Returns a L<Gitalist::Git::Repository> for the given name.
77 If C<$name> is not a valid git repository under C<$repo_dir>, an exception
84 L<Gitalist::Git::Repository>
89 See L<Gitalist> for authors.
93 See L<Gitalist> for the license.