X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FSetup.pm;h=fe8036c6ff7a441d284ff3db209f6515d2c07950;hb=5da4f9c64271928011b9f28e4ba68786bbdf7d0b;hp=ac2f1a52570b4ba5981d15d8c9366302da01ea6c;hpb=5d9a6d472d46896c9f878011e34485de7508c326;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Setup.pm b/lib/Catalyst/Setup.pm index ac2f1a5..fe8036c 100644 --- a/lib/Catalyst/Setup.pm +++ b/lib/Catalyst/Setup.pm @@ -1,12 +1,15 @@ package Catalyst::Setup; use strict; +use base qw/Class::Data::Inheritable/; use Catalyst::Exception; use Catalyst::Log; use Catalyst::Utils; use Path::Class; use Text::ASCIITable; +__PACKAGE__->mk_classdata($_) for qw/arguments dispatcher engine log/; + =head1 NAME Catalyst::Setup - The Catalyst Setup class @@ -21,7 +24,48 @@ See L. =over 4 -=item $class->setup_components +=item $c->setup + +Setup. + + $c->setup; + +=cut + +sub setup { + my $class = shift; + + # Call plugins setup + $class->NEXT::setup; + + # Initialize our data structure + $class->components( {} ); + + $class->setup_components; + + if ( $class->debug ) { + my $t = Text::ASCIITable->new; + $t->setOptions( 'hide_HeadRow', 1 ); + $t->setOptions( 'hide_HeadLine', 1 ); + $t->setCols('Class'); + $t->setColWidth( 'Class', 75, 1 ); + $t->addRow($_) for sort keys %{ $class->components }; + $class->log->debug( "Loaded components:\n" . $t->draw ) + if ( @{ $t->{tbl_rows} } ); + } + + # Add our self to components, since we are also a component + $class->components->{$class} = $class; + + $class->setup_actions; + + if ( $class->debug ) { + my $name = $class->config->{name} || 'Application'; + $class->log->info("$name powered by Catalyst $Catalyst::VERSION"); + } +} + +=item $c->setup_components Setup components.