Commit | Line | Data |
a18818fd |
1 | package Gitalist::ScriptRole; |
2 | use Moose::Role; |
3 | use MooseX::Types::Common::String qw/NonEmptySimpleStr/; |
4 | use namespace::autoclean; |
5 | |
6 | has repo_dir => ( |
7 | isa => NonEmptySimpleStr, is => 'ro', |
8 | predicate => 'has_repo_dir' |
9 | ); |
10 | |
11 | before 'run' => sub { |
12 | my $self = shift; |
13 | if ($self->has_repo_dir) { |
14 | # FIXME - This seems gross. I should be able to pass things through |
15 | # to the app instance, but the params are sent to the engine |
16 | # and not actually used to construct the app.. Not that |
17 | # $ENV{GITLIST_REPO_DIR} is a bad move, just that that being |
18 | # the mechanism by which this works that is non optimum. |
19 | $ENV{GITALIST_REPO_DIR} = $self->repo_dir; |
20 | } |
21 | }; |
22 | |
23 | 1; |
24 | |
e56c039f |
25 | =head1 NAME |
26 | |
27 | Gitalist::ScriptRole - Role for Gitalist scripts. |
28 | |
29 | =head1 DESCRIPTION |
30 | |
31 | Wraps the run method in Catalyst scripts to apply the C<< --repo_dir >> |
32 | option. |
33 | |
34 | =head1 AUTHORS |
35 | |
36 | See L<Gitalist> for authors. |
37 | |
38 | =head1 LICENSE |
39 | |
40 | See L<Gitalist> for the license. |
41 | |
42 | =cut |