[Jifty-commit] r2238 - jifty/trunk/lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Nov 30 23:43:40 EST 2006


Author: audreyt
Date: Thu Nov 30 23:43:40 2006
New Revision: 2238

Modified:
   jifty/trunk/lib/Jifty/Dispatcher.pm

Log:
* Jifty::Dispatcher - NUMBER SIGN (#) now captures one or more digit
  characters in the extended shellglob condition syntax.
  Suggested by: Sebastian Riedel

Modified: jifty/trunk/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Dispatcher.pm	(original)
+++ jifty/trunk/lib/Jifty/Dispatcher.pm	Thu Nov 30 23:43:40 2006
@@ -452,6 +452,7 @@
 
     # XXX TODO: refactor this out somehow?
     # We don't want the previous mason request hanging aroudn once we start dispatching
+    no warnings 'once';
     local $HTML::Mason::Commands::m = undef;
     # Mason introduces a DIE handler that generates a mason exception
     # which in turn generates a backtrace. That's fine when you only
@@ -841,8 +842,8 @@
 the condition defined by CONDITION. 
 
 C<CONDITION> can be a regular expression, a "simple string" with shell
-wildcard characters (C<*> and C<?>) to match against, or an arrayref or hashref
-of those. It should even be nestable.
+wildcard characters (C<*>, C<?>, C<#>, C<[]>, C<{}>) to match against,
+or an arrayref or hashref of those. It should even be nestable.
 
 Arrayref conditions represents alternatives: the match succeeds as soon
 as the first match is found.
@@ -943,7 +944,7 @@
     $cond =~ s{(?:\\\/)+}{/}g;
     $cond =~ s{/$}{};
 
-    my $has_capture = ( $cond =~ / \\ [*?] /x);
+    my $has_capture = ( $cond =~ / \\ [*?#] /x);
     if ($has_capture or $cond =~ / \\ [[{] /x) {
         $cond = $self->_compile_glob($cond);
     }
@@ -984,9 +985,9 @@
 
 Private function.
 
-Turns a metaexpression containing C<*> and C<?> into a capturing regex pattern.
+Turns a metaexpression containing C<*>, C<?> and C<#> into a capturing regex pattern.
 
-Also supports the non-capturing C<[]> and C<{}> notation.
+Also supports the non-capturing C<[]>,and C<{}> notation.
 
 The rules are:
 
@@ -1027,6 +1028,10 @@
 
 =item *
 
+The C<#> character captures one or more digit characters.
+
+=item *
+
 Brackets such as C<[a-z]> denote character classes; they are not captured.
 
 =item *
@@ -1055,6 +1060,10 @@
         \\ \*
     }{([^/]*)}gx;
     $glob =~ s{
+        # The number-sign character matches one or more digits.
+        \\ \#
+    }{(\\d+)}gx;
+    $glob =~ s{
         # Consecutive question marks are captured as one unit;
         # we do this by capturing them and then repeat the result pattern
         # for that many times.  The divide-by-two takes care of the
@@ -1087,6 +1096,7 @@
             )+
         ) \\ \}         # closing (not part of expression)
     }{'(?:'.join('|', split(/\\,/, $1)).')'}egx;
+    warn $glob;
     $glob;
 }
 


More information about the Jifty-commit mailing list