case_sensitive config setting removed
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Utils.pm
index 5bff574..3fff3c6 100644 (file)
@@ -100,9 +100,9 @@ sub class2env {
     return uc($class);
 }
 
-=head2 class2prefix( $class, $case );
+=head2 class2prefix( $class );
 
-Returns the uri prefix for a class. If case is false the prefix is converted to lowercase.
+Returns the uri prefix for a class. The prefix is converted to lowercase.
 
     My::App::Controller::Foo::Bar becomes foo/bar
 
@@ -110,10 +110,9 @@ Returns the uri prefix for a class. If case is false the prefix is converted to
 
 sub class2prefix {
     my $class = shift || '';
-    my $case  = shift || 0;
     my $prefix;
     if ( $class =~ /^.+?::([MVC]|Model|View|Controller)::(.+)$/ ) {
-        $prefix = $case ? $2 : lc $2;
+        $prefix = lc $2;
         $prefix =~ s{::}{/}g;
     }
     return $prefix;
@@ -124,7 +123,7 @@ sub class2prefix {
 Returns a tempdir for a class. If create is true it will try to create the path.
 
     My::App becomes /tmp/my/app
-    My::App::C::Foo::Bar becomes /tmp/my/app/c/foo/bar
+    My::App::Controller::Foo::Bar becomes /tmp/my/app/c/foo/bar
 
 =cut
 
@@ -172,8 +171,9 @@ sub home {
             # pop off /lib and /blib if they're there
             $home = $home->parent while $home =~ /b?lib$/;
 
-            # only return the dir if it has a Makefile.PL or Build.PL
-            if (-f $home->file("Makefile.PL") or -f $home->file("Build.PL")) {
+            # only return the dir if it has a Makefile.PL or Build.PL or dist.ini
+            if (-f $home->file("Makefile.PL") or -f $home->file("Build.PL")
+                or -f $home->file("dist.ini")) {
 
                 # clean up relative path:
                 # MyApp/script/.. -> MyApp
@@ -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);
 }