[Jifty-commit] r1091 - jifty/trunk/lib/Jifty
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Mon May 22 21:53:13 EDT 2006
Author: audreyt
Date: Mon May 22 21:53:12 2006
New Revision: 1091
Modified:
jifty/trunk/lib/Jifty/Dispatcher.pm
Log:
* Jifty::Dispatcher - support for non-capturing [a-z] in shellglobs.
Modified: jifty/trunk/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Dispatcher.pm (original)
+++ jifty/trunk/lib/Jifty/Dispatcher.pm Mon May 22 21:53:12 2006
@@ -943,7 +943,8 @@
Private function.
-Turns a metaexpression containing * and ? into a capturing perl regex pattern.
+Turns a metaexpression containing *, ? into a capturing perl regex pattern.
+Also supports the noncapturing [] notation.
The rules are:
@@ -974,6 +975,10 @@
/foo???bar # One capture for ???
/foo??* # Two captures, one for ?? and one for *
+=item *
+
+Character classes C<[a-z]> denote character classes; they are not captured.
+
=back
=cut
@@ -998,9 +1003,28 @@
# extra backslashes.
( (?: \\ \? )+ )
}{([^/]{${ \( length($1)/2 ) }})}gx;
+ $glob =~ s{
+ # Brackets denote character classes
+ (
+ \\ \[ # opening
+ (?: # one or more characters:
+ \\ [^\]] # ...escaped (but not the closing bracket)
+ |
+ [^\\] # ...normal
+ )+
+ \\ \] # closing
+ )
+ }{$self->_unescape($1)}egx;
$glob;
}
+sub _unescape {
+ my $self = shift;
+ my $text = shift;
+ $text =~ s{\\(.)}{$1}g;
+ return $text;
+}
+
=head2 template_exists PATH
Returns true if PATH is a valid template inside your template root.
More information about the Jifty-commit
mailing list