[interchange-cvs] interchange - jon modified lib/Vend/Interpolate.pm
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Fri Aug 8 16:29:00 EDT 2003
User: jon
Date: 2003-08-08 19:29:29 GMT
Modified: lib/Vend Interpolate.pm
Log:
Add three new filters:
alpha - keep only alphabetics A-Z and a-z
pgbool - munge any value into a valid PostgreSQL boolean to be used in a
quotable string environment, with a hybrid of Perl/Interchange/PostgreSQL
truth rules:
undef, '', F, f, 0 -> f
everything else -> t
pgbooln - same as pgbool, except assume that undefs will pass through as
NULLs to whatever does the query:
undef -> NULL
'', F, f, 0 -> f
everything else -> t
(The pgbool filters are an easy way to keep the table editor from trying
to insert invalid data into boolean fields and annoying users.)
Also a tiny simplification of the alphanumeric filter.
Revision Changes Path
2.188 +23 -4 interchange/lib/Vend/Interpolate.pm
rev 2.188, prev_rev 2.187
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.187
retrieving revision 2.188
diff -u -u -r2.187 -r2.188
--- Interpolate.pm 4 Aug 2003 05:11:20 -0000 2.187
+++ Interpolate.pm 8 Aug 2003 19:29:29 -0000 2.188
@@ -1,6 +1,6 @@
# Vend::Interpolate - Interpret Interchange tags
#
-# $Id: Interpolate.pm,v 2.187 2003/08/04 05:11:20 mheins Exp $
+# $Id: Interpolate.pm,v 2.188 2003/08/08 19:29:29 jon Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -28,7 +28,7 @@
require Exporter;
@ISA = qw(Exporter);
-$VERSION = substr(q$Revision: 2.187 $, 10);
+$VERSION = substr(q$Revision: 2.188 $, 10);
@EXPORT = qw (
@@ -1036,10 +1036,14 @@
$val =~ s/\D+//g;
return $val;
},
+ 'alpha' => sub {
+ my $val = shift;
+ $val =~ s/[^A-Za-z]+//g;
+ return $val;
+ },
'alphanumeric' => sub {
my $val = shift;
- $val =~ s/\W+//g;
- $val =~ s/_+//g;
+ $val =~ s/[^A-Za-z0-9]+//g;
return $val;
},
'word' => sub {
@@ -1173,6 +1177,21 @@
$_[0] =~ /^0*(.*)/; return $1;
},
+ pgbool => sub {
+ my $val = shift;
+ return 'f' if ! defined($val);
+ $val =~ s/\s+//g;
+ return 'f' if $val =~ /^[Ff0]?$/;
+ return 't';
+ },
+
+ pgbooln => sub {
+ my $val = shift;
+ return if ! defined($val);
+ $val =~ s/\s+//g;
+ return 'f' if $val =~ /^[Ff0]?$/;
+ return 't';
+ },
);
$Filter{upper} = $Filter{uc};
More information about the interchange-cvs
mailing list