From: Sebastian Riedel Date: Wed, 8 Jun 2005 19:58:11 +0000 (+0000) Subject: Added support for case sensitivity X-Git-Tag: 5.7099_04~1328 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=e494bd6b47c5dc60ca4b822825f5d73a93c9b4e6 Added support for case sensitivity --- diff --git a/Changes b/Changes index dd3c538..3ee13a5 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,7 @@ This file documents the revision history for Perl extension Catalyst. 5.24 2005-06-03 02:30:00 - Prettify home path by resolving '..' (Andy Grundman) - Improved helper templates a bit, new naming scheme for tests... + - Added support for case sensitivity, MyApp->config->{case_sensitive} 5.23 2005-06-03 02:30:00 - added support for non Catalyst::Base components to live in namespace diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 4bd1a43..3ff54ba 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -38,8 +38,8 @@ sub dispatch { unless ($namespace) { if ( my $result = $c->get_action($action) ) { - $namespace = - Catalyst::Utils::class2prefix( $result->[0]->[0]->[0] ); + $namespace = Catalyst::Utils::class2prefix( $result->[0]->[0]->[0], + $c->config->{case_sensitive} ); } } @@ -122,7 +122,11 @@ sub forward { $command =~ s/^\///; } - else { $namespace = Catalyst::Utils::class2prefix($caller) || '/' } + else { + $namespace = + Catalyst::Utils::class2prefix( $caller, $c->config->{case_sensitive} ) + || '/'; + } my $results = $c->get_action( $command, $namespace ); @@ -258,7 +262,9 @@ Set an action in a given namespace. sub set_action { my ( $c, $method, $code, $namespace, $attrs ) = @_; - my $prefix = Catalyst::Utils::class2prefix($namespace) || ''; + my $prefix = + Catalyst::Utils::class2prefix( $namespace, $c->config->{case_sensitive} ) + || ''; my %flags; for my $attr ( @{$attrs} ) { @@ -362,10 +368,10 @@ sub setup_actions { # We use a tree $self->tree( Tree::Simple->new( 0, Tree::Simple->ROOT ) ); - + for my $comp ( keys %{ $self->components } ) { - - # We only setup components that inherit from Catalyst::Base + + # We only setup components that inherit from Catalyst::Base next unless $comp->isa('Catalyst::Base'); for my $action ( @{ Catalyst::Utils::reflect_actions($comp) } ) { @@ -402,7 +408,7 @@ sub setup_actions { } } - + return unless $self->debug; my $actions = $self->actions; diff --git a/lib/Catalyst/Utils.pm b/lib/Catalyst/Utils.pm index 8b3dc2e..50fb0c3 100644 --- a/lib/Catalyst/Utils.pm +++ b/lib/Catalyst/Utils.pm @@ -79,7 +79,7 @@ sub class2classsuffix { return $class; } -=item class2prefix($class); +=item class2prefix( $class, $case ); Returns the prefix for class. @@ -89,9 +89,10 @@ Returns the prefix for class. sub class2prefix { my $class = shift || ''; + my $case = shift || 0; my $prefix; if ( $class =~ /^.*::([MVC]|Model|View|Controller)?::(.*)$/ ) { - $prefix = lc $2; + $prefix = $case ? $2 : lc $2; $prefix =~ s/\:\:/\//g; } return $prefix;