Fix annoying warnings in Utils::resolve_namespace.
Florian Ragwitz [Fri, 26 Jun 2009 19:45:45 +0000 (19:45 +0000)]
Also get rid of some other nits introduced with resolve_namespace.

lib/Catalyst.pm
lib/Catalyst/Dispatcher.pm
lib/Catalyst/Utils.pm
t/aggregate/live_component_controller_action_action.t

index 435eee6..9a886e6 100644 (file)
@@ -2511,7 +2511,7 @@ the plugin name does not begin with C<Catalyst::Plugin::>.
 
         $class->_plugins( {} ) unless $class->_plugins;
         $plugins ||= [];
-                
+
         my @plugins = Catalyst::Utils::resolve_namespace($class . '::Plugin', 'Catalyst::Plugin', @$plugins);
 
         for my $plugin ( reverse @plugins ) {
index 5a975ed..d54d2ea 100644 (file)
@@ -680,7 +680,7 @@ of course it's being used.)
 
 sub dispatch_type {
     my ($self, $name) = @_;
-    
+
     # first param is undef because we cannot get the appclass
     $name = Catalyst::Utils::resolve_namespace(undef, 'Catalyst::DispatchType', $name);
 
index 5bff574..05248fc 100644 (file)
@@ -385,7 +385,7 @@ sub term_width {
 Method which adds the namespace for plugins and actions.
 
   __PACKAGE__->setup(qw(MyPlugin));
-  
+
   # will load Catalyst::Plugin::MyPlugin
 
 =cut
@@ -395,9 +395,14 @@ sub resolve_namespace {
     my $appnamespace = shift;
     my $namespace = shift;
     my @classes = @_;
-    return String::RewritePrefix->rewrite(
-        { '' => $namespace.'::', '+' => '', '~' => $appnamespace . '::' }, @classes,
-      );
+    return String::RewritePrefix->rewrite({
+        q[]  => qq[${namespace}::],
+        q[+] => q[],
+        (defined $appnamespace
+            ? (q[~] => qq[${appnamespace}::])
+            : ()
+        ),
+    }, @classes);
 }
 
 
index 1e11b18..fd2b4cd 100644 (file)
@@ -106,7 +106,7 @@ sub run_tests {
             'Content is a serialized Catalyst::Request'
         );
     }
-    
+
     {
         ok( my $response = request('http://localhost/action_action_five'),
             'Request' );
@@ -126,7 +126,6 @@ sub run_tests {
             'Content is a serialized Catalyst::Request'
         );
     }
-    
 
     {
         ok( my $response = request('http://localhost/action_action_six'),