X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=9a1149b614e73795523c19212947a8bfe53728aa;hb=fd59198f81df808d08ec0720d6ef667ef34921ab;hp=6c72b8b20840e6067633d126a649b6df93f222c6;hpb=5d9a6d472d46896c9f878011e34485de7508c326;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 6c72b8b..9a1149b 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -13,7 +13,7 @@ our $CATALYST_SCRIPT_GEN = 4; __PACKAGE__->mk_classdata($_) for qw/arguments dispatcher engine log/; -our $VERSION = '5.24'; +our $VERSION = '5.34'; our @ISA; =head1 NAME @@ -127,94 +127,19 @@ Returns a hashref containing your applications settings. sub import { my ( $class, @arguments ) = @_; + # We have to limit $class to Catalyst to avoid pushing Catalyst upon every + # callers @ISA. + return unless $class eq 'Catalyst'; + my $caller = caller(0); - - if ( $caller eq 'main' ) { - return; - } - # Prepare inheritance - unless ( $caller->isa($class) ) { + unless ( $caller->isa('Catalyst') ) { no strict 'refs'; push @{"$caller\::ISA"}, $class; } - - if ( $caller->engine ) { - $caller->log->warn( qq/Attempt to re-initialize "$caller"/ ); - return; - } - - # Process options - my $flags = { }; - - foreach (@arguments) { - - if ( /^-Debug$/ ) { - $flags->{log} = ( $flags->{log} ) ? 'debug,' . $flags->{log} : 'debug'; - } - elsif (/^-(\w+)=?(.*)$/) { - $flags->{ lc $1 } = $2; - } - else { - push @{ $flags->{plugins} }, $_; - } - } - - $caller->setup_log ( delete $flags->{log} ); - $caller->setup_plugins ( delete $flags->{plugins} ); - $caller->setup_dispatcher ( delete $flags->{dispatcher} ); - $caller->setup_engine ( delete $flags->{engine} ); - $caller->setup_home ( delete $flags->{home} ); - - for my $flag ( sort keys %{ $flags } ) { - - if ( my $code = $caller->can( 'setup_' . $flag ) ) { - &$code( $caller, delete $flags->{$flag} ); - } - else { - $caller->log->warn(qq/Unknown flag "$flag"/); - } - } - - $caller->log->warn( "You are running an old helper script! " - . "Please update your scripts by regenerating the " - . "application and copying over the new scripts." ) - if ( $ENV{CATALYST_SCRIPT_GEN} - && ( $ENV{CATALYST_SCRIPT_GEN} < $CATALYST_SCRIPT_GEN ) ); - - if ( $caller->debug ) { - - my @plugins = (); - - { - no strict 'refs'; - @plugins = grep { /^Catalyst::Plugin/ } @{"$caller\::ISA"}; - } - - if ( @plugins ) { - 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 @plugins; - $caller->log->debug( "Loaded plugins:\n" . $t->draw ); - } - - my $dispatcher = $caller->dispatcher; - my $engine = $caller->engine; - my $home = $caller->config->{home}; - - $caller->log->debug(qq/Loaded dispatcher "$dispatcher"/); - $caller->log->debug(qq/Loaded engine "$engine"/); - - $home - ? ( -d $home ) - ? $caller->log->debug(qq/Found home "$home"/) - : $caller->log->debug(qq/Home "$home" doesn't exist/) - : $caller->log->debug(q/Couldn't find home/); - } + $caller->arguments( [ @arguments ] ); + $caller->setup_home; } =item $c->engine @@ -269,48 +194,16 @@ sub plugin { if $class->debug; } -=item $class->setup - -Setup. - - MyApp->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} } ); - } +=back - # Add our self to components, since we are also a component - $class->components->{$class} = $class; +=head1 CASE SENSITIVITY - $class->setup_actions; +By default Catalyst is not case sensitive, so C becomes +C. - if ( $class->debug ) { - my $name = $class->config->{name} || 'Application'; - $class->log->info("$name powered by Catalyst $Catalyst::VERSION"); - } -} +But you can activate case sensitivity with a config parameter. -=back + MyApp->config->{case_sensitive} = 1; =head1 LIMITATIONS @@ -349,17 +242,55 @@ Web: =back -=head1 AUTHOR +=head1 CREDITS -Sebastian Riedel, C +Andy Grundman + +Andrew Ford + +Andrew Ruthven + +Autrijus Tang + +Christian Hansen + +Christopher Hicks + +Dan Sully + +Danijel Milicevic + +David Naughton + +Gary Ashton Jones -=head1 THANK YOU +Geoff Richards -Andy Grundman, Andrew Ford, Andrew Ruthven, Autrijus Tang, Christian Hansen, -Christopher Hicks, Dan Sully, Danijel Milicevic, David Naughton, -Gary Ashton Jones, Geoff Richards, Jesse Sheidlower, Jody Belka, -Johan Lindstrom, Juan Camacho, Leon Brocard, Marcus Ramberg, -Tatsuhiko Miyagawa and all the others who've helped. +Jesse Sheidlower + +Jody Belka + +Johan Lindstrom + +Juan Camacho + +Leon Brocard + +Marcus Ramberg + +Matt S Trout + +Robert Sedlacek + +Sebastian Riedel + +Tatsuhiko Miyagawa + +Ulf Edvinsson + +=head1 AUTHOR + +Sebastian Riedel, C =head1 LICENSE