incorporated static discussion from andyg into Cookbook.pod
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index c5b03e3..2c6ca19 100644 (file)
@@ -11,7 +11,9 @@ use Text::ASCIITable;
 use Path::Class;
 our $CATALYST_SCRIPT_GEN = 4;
 
-our $VERSION = '5.24';
+__PACKAGE__->mk_classdata($_) for qw/arguments dispatcher engine log/;
+
+our $VERSION = '5.31';
 our @ISA;
 
 =head1 NAME
@@ -125,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,6 +196,15 @@ sub plugin {
 
 =back
 
+=head1 CASE SENSITIVITY
+
+By default Catalyst is not case sensitive, so C<MyApp::C::FOO::Bar> becomes
+C</foo/bar>.
+
+But you can activate case sensitivity with a config parameter.
+
+    MyApp->config->{case_sensitive} = 1;
+
 =head1 LIMITATIONS
 
 mod_perl2 support is considered experimental and may contain bugs.