X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FIOC%2FContainer.pm;h=9a9137c5a5d10cc6715456a002bbebd47b21baaa;hb=d9a59c532eec44e3c85a44566a2e1afbb0c22c93;hp=f8a9e97a0461407395d263062f05761e118797cc;hpb=96c9f5d4c9cebf815970a5ea94b90ad693ebaa93;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/IOC/Container.pm b/lib/Catalyst/IOC/Container.pm index f8a9e97..9a9137c 100644 --- a/lib/Catalyst/IOC/Container.pm +++ b/lib/Catalyst/IOC/Container.pm @@ -17,6 +17,12 @@ use namespace::autoclean; extends 'Bread::Board::Container'; +has flags => ( + is => 'ro', + isa => 'ArrayRef', + default => sub { [] }, +); + has config_local_suffix => ( is => 'ro', isa => 'Str', @@ -74,6 +80,9 @@ sub BUILD { config_local_suffix config_path locate_components + flags + home + root_dir /; my $config = $self->resolve( service => 'config' ); @@ -145,6 +154,36 @@ sub build_component_subcontainer { ); } +sub build_flags_service { + my $self = shift; + + return Bread::Board::Literal->new( + lifecycle => 'Singleton', + name => 'flags', + value => $self->get_flags, + ); +} + +sub get_flags { + my $self = shift; + my $flags = {}; + + foreach (@{ $self->flags }) { + if (/^-Debug$/) { + $flags->{log} = + ( $flags->{log} ) ? 'debug,' . $flags->{log} : 'debug'; + } + elsif (/^-(\w+)=?(.*)$/) { + $flags->{ lc $1 } = $2; + } + else { + push @{ $flags->{plugins} }, $_; + } + } + + return $flags; +} + sub build_home_service { my $self = shift; @@ -152,18 +191,20 @@ sub build_home_service { lifecycle => 'Singleton', name => 'home', block => sub { - my $self = shift; + my $self = shift; my $class = $self->param('catalyst_application'); - my $home; if ( my $env = Catalyst::Utils::env_value( $class, 'HOME' ) ) { - $home = $env; + return $env; } - $home ||= Catalyst::Utils::home($class); - return $home; + if ( my $home = $self->param('flags')->{home} ) { + return $home; + } + + return Catalyst::Utils::home($class); }, - dependencies => [ depends_on('catalyst_application') ], + dependencies => [ depends_on('flags'), depends_on('catalyst_application') ], ); } @@ -805,6 +846,17 @@ Same as L, but for controllers. Name of the application (such as MyApp). +=head2 build_home_service + +The application home directory. All the files (including classes, scripts, etc) +created for this application are in this directory, or in a sub-directory below +this one. + +=head2 build_root_dir_service + +Inside the application home (as explained in L), there is +a root directory. This is where all templates and static files are. + =head2 build_driver_service Config options passed directly to the driver being used.