From: Tomas Doran Date: Wed, 9 Nov 2011 23:39:58 +0000 (+0000) Subject: Less madness with the environment. Not tested X-Git-Tag: 0.003007~22^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5e26dc93f7d8f6b3a9df80f69b3cc5f3f477f8be;hp=f444707fbb36619b419eb2aa7a9c297fa5d5534f;p=catagits%2FGitalist.git Less madness with the environment. Not tested --- diff --git a/lib/Gitalist/Model/CollectionOfRepos.pm b/lib/Gitalist/Model/CollectionOfRepos.pm index 1e709c4..4cc901e 100644 --- a/lib/Gitalist/Model/CollectionOfRepos.pm +++ b/lib/Gitalist/Model/CollectionOfRepos.pm @@ -12,6 +12,7 @@ use namespace::autoclean; extends 'Catalyst::Model'; +with 'Catalyst::Component::ApplicationAttribute'; with 'Catalyst::Component::InstancePerContext'; my $repo_dir_t = subtype NonEmptySimpleStr, @@ -79,8 +80,10 @@ has whitelist => ( sub _build_repo_dir { my $self = shift; - $ENV{GITALIST_REPO_DIR} ? - $ENV{GITALIST_REPO_DIR} + my $repo_dir = $self->_application->run_options->{repo_dir}; + + $repo_dir ? + $repo_dir : $self->has_config_repo_dir ? $self->config_repo_dir : ''; diff --git a/lib/Gitalist/ScriptRole.pm b/lib/Gitalist/ScriptRole.pm index db59bab..65de673 100644 --- a/lib/Gitalist/ScriptRole.pm +++ b/lib/Gitalist/ScriptRole.pm @@ -1,25 +1,18 @@ package Gitalist::ScriptRole; use Moose::Role; +use MooseX::Types::Moose qw/ Undef /; use MooseX::Types::Common::String qw/NonEmptySimpleStr/; use namespace::autoclean; has repo_dir => ( - isa => NonEmptySimpleStr, is => 'ro', - predicate => 'has_repo_dir' + isa => Undef | NonEmptySimpleStr, + is => 'ro', + default => sub { + return unless exists $ENV{GITALIST_REPO_DIR}; + $ENV{GITALIST_REPO_DIR}; + }, ); -before 'run' => sub { - my $self = shift; - if ($self->has_repo_dir) { - # FIXME - This seems gross. I should be able to pass things through - # to the app instance, but the params are sent to the engine - # and not actually used to construct the app.. Not that - # $ENV{GITLIST_REPO_DIR} is a bad move, just that that being - # the mechanism by which this works that is non optimum. - $ENV{GITALIST_REPO_DIR} = $self->repo_dir; - } -}; - 1; =head1 NAME