r43632 - in /branches/upstream/libsql-abstract-perl/current: ./ inc/Module/ inc/Module/Install/ lib/SQL/ t/
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Fri Sep 4 03:39:13 UTC 2009
Author: jawnsy-guest
Date: Fri Sep 4 03:38:06 2009
New Revision: 43632
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=43632
Log:
[svn-upgrade] Integrating new upstream version, libsql-abstract-perl (1.57)
Added:
branches/upstream/libsql-abstract-perl/current/t/90pod.t
branches/upstream/libsql-abstract-perl/current/t/91podcoverage.t
Modified:
branches/upstream/libsql-abstract-perl/current/Changes
branches/upstream/libsql-abstract-perl/current/MANIFEST
branches/upstream/libsql-abstract-perl/current/META.yml
branches/upstream/libsql-abstract-perl/current/inc/Module/Install.pm
branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Base.pm
branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Can.pm
branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Fetch.pm
branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Makefile.pm
branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Metadata.pm
branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Win32.pm
branches/upstream/libsql-abstract-perl/current/inc/Module/Install/WriteAll.pm
branches/upstream/libsql-abstract-perl/current/lib/SQL/Abstract.pm
branches/upstream/libsql-abstract-perl/current/t/02where.t
Modified: branches/upstream/libsql-abstract-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/Changes?rev=43632&op=diff
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/Changes (original)
+++ branches/upstream/libsql-abstract-perl/current/Changes Fri Sep 4 03:38:06 2009
@@ -1,4 +1,8 @@
Revision history for SQL::Abstract
+
+revision 1.57 2009-09-03 20:18 (UTC)
+----------------------------
+ - added -bool and -not_bool operators
revision 1.56 2009-05-30 16:31 (UTC)
----------------------------
Modified: branches/upstream/libsql-abstract-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/MANIFEST?rev=43632&op=diff
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/MANIFEST (original)
+++ branches/upstream/libsql-abstract-perl/current/MANIFEST Fri Sep 4 03:38:06 2009
@@ -24,3 +24,5 @@
t/08special_ops.t
t/09refkind.t
t/10test.t
+t/90pod.t
+t/91podcoverage.t
Modified: branches/upstream/libsql-abstract-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/META.yml?rev=43632&op=diff
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/META.yml (original)
+++ branches/upstream/libsql-abstract-perl/current/META.yml Fri Sep 4 03:38:06 2009
@@ -13,7 +13,7 @@
configure_requires:
ExtUtils::MakeMaker: 6.42
distribution_type: module
-generated_by: 'Module::Install version 0.90'
+generated_by: 'Module::Install version 0.91'
license: gpl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -29,4 +29,4 @@
perl: 5.6.1
resources:
license: http://opensource.org/licenses/gpl-license.php
-version: 1.56
+version: 1.57
Modified: branches/upstream/libsql-abstract-perl/current/inc/Module/Install.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/inc/Module/Install.pm?rev=43632&op=diff
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/inc/Module/Install.pm (original)
+++ branches/upstream/libsql-abstract-perl/current/inc/Module/Install.pm Fri Sep 4 03:38:06 2009
@@ -28,7 +28,7 @@
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
- $VERSION = '0.90';
+ $VERSION = '0.91';
# Storage for the pseudo-singleton
$MAIN = undef;
Modified: branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Base.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Base.pm?rev=43632&op=diff
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Base.pm (original)
+++ branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Base.pm Fri Sep 4 03:38:06 2009
@@ -4,7 +4,7 @@
use strict 'vars';
use vars qw{$VERSION};
BEGIN {
- $VERSION = '0.90';
+ $VERSION = '0.91';
}
# Suspend handler for "redefined" warnings
Modified: branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Can.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Can.pm?rev=43632&op=diff
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Can.pm (original)
+++ branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Can.pm Fri Sep 4 03:38:06 2009
@@ -9,7 +9,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.90';
+ $VERSION = '0.91';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
Modified: branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Fetch.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Fetch.pm?rev=43632&op=diff
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Fetch.pm (original)
+++ branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Fetch.pm Fri Sep 4 03:38:06 2009
@@ -6,7 +6,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.90';
+ $VERSION = '0.91';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
Modified: branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Makefile.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Makefile.pm?rev=43632&op=diff
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Makefile.pm (original)
+++ branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Makefile.pm Fri Sep 4 03:38:06 2009
@@ -7,7 +7,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.90';
+ $VERSION = '0.91';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
Modified: branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Metadata.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Metadata.pm?rev=43632&op=diff
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Metadata.pm (original)
+++ branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Metadata.pm Fri Sep 4 03:38:06 2009
@@ -6,7 +6,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.90';
+ $VERSION = '0.91';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -505,6 +505,17 @@
}
}
+sub test_requires_from {
+ my $self = shift;
+ my $content = Module::Install::_readperl($_[0]);
+ my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg;
+ while ( @requires ) {
+ my $module = shift @requires;
+ my $version = shift @requires;
+ $self->test_requires( $module => $version );
+ }
+}
+
# Convert triple-part versions (eg, 5.6.1 or 5.8.9) to
# numbers (eg, 5.006001 or 5.008009).
# Also, convert double-part versions (eg, 5.8)
Modified: branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Win32.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Win32.pm?rev=43632&op=diff
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Win32.pm (original)
+++ branches/upstream/libsql-abstract-perl/current/inc/Module/Install/Win32.pm Fri Sep 4 03:38:06 2009
@@ -6,7 +6,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.90';
+ $VERSION = '0.91';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
Modified: branches/upstream/libsql-abstract-perl/current/inc/Module/Install/WriteAll.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/inc/Module/Install/WriteAll.pm?rev=43632&op=diff
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/inc/Module/Install/WriteAll.pm (original)
+++ branches/upstream/libsql-abstract-perl/current/inc/Module/Install/WriteAll.pm Fri Sep 4 03:38:06 2009
@@ -6,7 +6,7 @@
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '0.90';;
+ $VERSION = '0.91';;
@ISA = qw{Module::Install::Base};
$ISCORE = 1;
}
Modified: branches/upstream/libsql-abstract-perl/current/lib/SQL/Abstract.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/lib/SQL/Abstract.pm?rev=43632&op=diff
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/lib/SQL/Abstract.pm (original)
+++ branches/upstream/libsql-abstract-perl/current/lib/SQL/Abstract.pm Fri Sep 4 03:38:06 2009
@@ -15,7 +15,7 @@
# GLOBALS
#======================================================================
-our $VERSION = '1.56';
+our $VERSION = '1.57';
# This would confuse some packagers
#$VERSION = eval $VERSION; # numify for warning-free dev releases
@@ -29,6 +29,15 @@
{regex => qr/^(not )?in$/i, handler => '_where_field_IN'},
);
+# unaryish operators - key maps to handler
+my @BUILTIN_UNARY_OPS = (
+ # the digits are backcompat stuff
+ { regex => qr/^and (?: \s? \d+ )? $/xi, handler => '_where_op_ANDOR' },
+ { regex => qr/^or (?: \s? \d+ )? $/xi, handler => '_where_op_ANDOR' },
+ { regex => qr/^nest (?: \s? \d+ )? $/xi, handler => '_where_op_NEST' },
+ { regex => qr/^ (?: not \s )? bool $/xi, handler => '_where_op_BOOL' },
+);
+
#======================================================================
# DEBUGGING AND ERROR REPORTING
#======================================================================
@@ -85,6 +94,10 @@
# special operators
$opt{special_ops} ||= [];
push @{$opt{special_ops}}, @BUILTIN_SPECIAL_OPS;
+
+ # unary operators
+ $opt{unary_ops} ||= [];
+ push @{$opt{unary_ops}}, @BUILTIN_UNARY_OPS;
return bless \%opt, $class;
}
@@ -426,7 +439,7 @@
my $v = $where->{$k};
# ($k => $v) is either a special op or a regular hashpair
- my ($sql, @bind) = ($k =~ /^-(.+)/) ? $self->_where_op_in_hash($1, $v)
+ my ($sql, @bind) = ($k =~ /^(-.+)/) ? $self->_where_op_in_hash($1, $v)
: do {
my $method = $self->_METHOD_FOR_refkind("_where_hashpair", $v);
$self->$method($k, $v);
@@ -441,49 +454,90 @@
sub _where_op_in_hash {
- my ($self, $op_str, $v) = @_;
-
- $op_str =~ /^ (AND|OR|NEST) ( \_? \d* ) $/xi
- or puke "unknown operator: -$op_str";
-
- my $op = uc($1); # uppercase, remove trailing digits
- if ($2) {
- belch 'Use of [and|or|nest]_N modifiers is deprecated and will be removed in SQLA v2.0. '
- . "You probably wanted ...-and => [ $op_str => COND1, $op_str => COND2 ... ]";
+ my ($self, $orig_op, $v) = @_;
+
+ # put the operator in canonical form
+ my $op = $orig_op;
+ $op =~ s/^-//; # remove initial dash
+ $op =~ s/[_\t ]+/ /g; # underscores and whitespace become single spaces
+ $op =~ s/^\s+|\s+$//g;# remove leading/trailing space
+
+ $self->_debug("OP(-$op) within hashref, recursing...");
+
+ my $op_entry = first {$op =~ $_->{regex}} @{$self->{unary_ops}};
+ my $handler = $op_entry->{handler};
+ if (! $handler) {
+ puke "unknown operator: $orig_op";
}
-
- $self->_debug("OP(-$op) within hashref, recursing...");
+ elsif (not ref $handler) {
+ if ($op =~ s/\s?\d+$//) {
+ belch 'Use of [and|or|nest]_N modifiers is deprecated and will be removed in SQLA v2.0. '
+ . "You probably wanted ...-and => [ -$op => COND1, -$op => COND2 ... ]";
+ }
+ return $self->$handler ($op, $v);
+ }
+ elsif (ref $handler eq 'CODE') {
+ return $handler->($self, $op, $v);
+ }
+ else {
+ puke "Illegal handler for operator $orig_op - expecting a method name or a coderef";
+ }
+}
+
+sub _where_op_ANDOR {
+ my ($self, $op, $v) = @_;
$self->_SWITCH_refkind($v, {
-
ARRAYREF => sub {
- return $self->_where_ARRAYREF($v, $op eq 'NEST' ? '' : $op);
+ return $self->_where_ARRAYREF($v, $op);
},
HASHREF => sub {
- if ($op eq 'OR') {
- return $self->_where_ARRAYREF([ map { $_ => $v->{$_} } (sort keys %$v) ], 'OR');
- }
- else { # NEST | AND
- return $self->_where_HASHREF($v);
- }
+ return ( $op =~ /^or/i )
+ ? $self->_where_ARRAYREF( [ map { $_ => $v->{$_} } ( sort keys %$v ) ], $op )
+ : $self->_where_HASHREF($v);
},
+ SCALARREF => sub {
+ puke "-$op => \\\$scalar not supported, use -nest => ...";
+ },
+
+ ARRAYREFREF => sub {
+ puke "-$op => \\[..] not supported, use -nest => ...";
+ },
+
+ SCALAR => sub { # permissively interpreted as SQL
+ puke "-$op => 'scalar' not supported, use -nest => \\'scalar'";
+ },
+
+ UNDEF => sub {
+ puke "-$op => undef not supported";
+ },
+ });
+}
+
+sub _where_op_NEST {
+ my ($self, $op, $v) = @_;
+
+ $self->_SWITCH_refkind($v, {
+
+ ARRAYREF => sub {
+ return $self->_where_ARRAYREF($v, '');
+ },
+
+ HASHREF => sub {
+ return $self->_where_HASHREF($v);
+ },
+
SCALARREF => sub { # literal SQL
- $op eq 'NEST'
- or puke "-$op => \\\$scalar not supported, use -nest => ...";
return ($$v);
},
ARRAYREFREF => sub { # literal SQL
- $op eq 'NEST'
- or puke "-$op => \\[..] not supported, use -nest => ...";
return @{${$v}};
},
SCALAR => sub { # permissively interpreted as SQL
- $op eq 'NEST'
- or puke "-$op => 'scalar' not supported, use -nest => \\'scalar'";
belch "literal SQL should be -nest => \\'scalar' "
. "instead of -nest => 'scalar' ";
return ($v);
@@ -491,6 +545,22 @@
UNDEF => sub {
puke "-$op => undef not supported";
+ },
+ });
+}
+
+
+sub _where_op_BOOL {
+ my ($self, $op, $v) = @_;
+
+ my $prefix = ($op =~ /\bnot\b/i) ? 'NOT ' : '';
+ $self->_SWITCH_refkind($v, {
+ SCALARREF => sub { # literal SQL
+ return ($prefix . $$v);
+ },
+
+ SCALAR => sub { # interpreted as SQL column
+ return ($prefix . $self->_convert($self->_quote($v)));
},
});
}
@@ -533,15 +603,14 @@
my ($all_sql, @all_bind);
- for my $op (sort keys %$v) {
- my $val = $v->{$op};
+ for my $orig_op (sort keys %$v) {
+ my $val = $v->{$orig_op};
# put the operator in canonical form
- $op =~ s/^-//; # remove initial dash
- $op =~ tr/_/ /; # underscores become spaces
- $op =~ s/^\s+//; # no initial space
- $op =~ s/\s+$//; # no final space
- $op =~ s/\s+/ /; # multiple spaces become one
+ my $op = $orig_op;
+ $op =~ s/^-//; # remove initial dash
+ $op =~ s/[_\t ]+/ /g; # underscores and whitespace become single spaces
+ $op =~ s/^\s+|\s+$//g;# remove leading/trailing space
my ($sql, @bind);
@@ -550,7 +619,7 @@
if ($special_op) {
my $handler = $special_op->{handler};
if (! $handler) {
- puke "No handler supplied for special operator matching $special_op->{regex}";
+ puke "No handler supplied for special operator $orig_op";
}
elsif (not ref $handler) {
($sql, @bind) = $self->$handler ($k, $op, $val);
@@ -559,7 +628,7 @@
($sql, @bind) = $handler->($self, $k, $op, $val);
}
else {
- puke "Illegal handler for special operator matching $special_op->{regex} - expecting a method name or a coderef";
+ puke "Illegal handler for special operator $orig_op - expecting a method name or a coderef";
}
}
else {
@@ -591,10 +660,10 @@
UNDEF => sub { # CASE: col => {op => undef} : sql "IS (NOT)? NULL"
my $is = ($op =~ $self->{equality_op}) ? 'is' :
($op =~ $self->{inequality_op}) ? 'is not' :
- puke "unexpected operator '$op' with undef operand";
+ puke "unexpected operator '$orig_op' with undef operand";
$sql = $self->_quote($k) . $self->_sqlcase(" $is null");
},
-
+
FALLBACK => sub { # CASE: col => {op => $scalar}
$sql = join ' ', $self->_convert($self->_quote($k)),
$self->_sqlcase($op),
@@ -800,8 +869,6 @@
return ($sql, @bind);
}
-
-
@@ -1549,6 +1616,12 @@
to extend the syntax understood by L<SQL::Abstract>.
See section L</"SPECIAL OPERATORS"> for details.
+=item unary_ops
+
+Takes a reference to a list of "unary operators"
+to extend the syntax understood by L<SQL::Abstract>.
+See section L</"UNARY OPERATORS"> for details.
+
=back
@@ -1868,6 +1941,24 @@
These are the two builtin "special operators"; but the
list can be expanded : see section L</"SPECIAL OPERATORS"> below.
+
+=head2 Unary operators: bool
+
+If you wish to test against boolean columns or functions within your
+database you can use the C<-bool> and C<-not_bool> operators. For
+example to test the column C<is_user> being true and the column
+<is_enabled> being false you would use:-
+
+ my %where = (
+ -bool => 'is_user',
+ -not_bool => 'is_enabled',
+ );
+
+Would give you:
+
+ WHERE is_user AND NOT is_enabled
+
+
=head2 Nested conditions, -and/-or prefixes
@@ -2247,6 +2338,59 @@
]);
+=head1 UNARY OPERATORS
+
+ my $sqlmaker = SQL::Abstract->new(unary_ops => [
+ {
+ regex => qr/.../,
+ handler => sub {
+ my ($self, $op, $arg) = @_;
+ ...
+ },
+ },
+ {
+ regex => qr/.../,
+ handler => 'method_name',
+ },
+ ]);
+
+A "unary operator" is a SQL syntactic clause that can be
+applied to a field - the operator goes before the field
+
+You can write your own operator handlers - supply a C<unary_ops>
+argument to the C<new> method. That argument takes an arrayref of
+operator definitions; each operator definition is a hashref with two
+entries:
+
+=over
+
+=item regex
+
+the regular expression to match the operator
+
+=item handler
+
+Either a coderef or a plain scalar method name. In both cases
+the expected return is C<< $sql >>.
+
+When supplied with a method name, it is simply called on the
+L<SQL::Abstract/> object as:
+
+ $self->$method_name ($op, $arg)
+
+ Where:
+
+ $op is the part that matched the handler regex
+ $arg is the RHS or argument of the operator
+
+When supplied with a coderef, it is called as:
+
+ $coderef->($self, $op, $arg)
+
+
+=back
+
+
=head1 PERFORMANCE
Thanks to some benchmarking by Mark Stosberg, it turns out that
Modified: branches/upstream/libsql-abstract-perl/current/t/02where.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/t/02where.t?rev=43632&op=diff
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/t/02where.t (original)
+++ branches/upstream/libsql-abstract-perl/current/t/02where.t Fri Sep 4 03:38:06 2009
@@ -216,6 +216,55 @@
stmt => " WHERE (foo = ?)",
bind => [ "bar" ],
},
+
+ {
+ where => { -bool => \'function(x)' },
+ stmt => " WHERE function(x)",
+ bind => [],
+ },
+
+ {
+ where => { -bool => 'foo' },
+ stmt => " WHERE foo",
+ bind => [],
+ },
+
+ {
+ where => { -and => [-bool => 'foo', -bool => 'bar'] },
+ stmt => " WHERE foo AND bar",
+ bind => [],
+ },
+
+ {
+ where => { -or => [-bool => 'foo', -bool => 'bar'] },
+ stmt => " WHERE foo OR bar",
+ bind => [],
+ },
+
+ {
+ where => { -not_bool => \'function(x)' },
+ stmt => " WHERE NOT function(x)",
+ bind => [],
+ },
+
+ {
+ where => { -not_bool => 'foo' },
+ stmt => " WHERE NOT foo",
+ bind => [],
+ },
+
+ {
+ where => { -and => [-not_bool => 'foo', -not_bool => 'bar'] },
+ stmt => " WHERE NOT foo AND NOT bar",
+ bind => [],
+ },
+
+ {
+ where => { -or => [-not_bool => 'foo', -not_bool => 'bar'] },
+ stmt => " WHERE NOT foo OR NOT bar",
+ bind => [],
+ },
+
);
plan tests => ( @handle_tests * 2 ) + 1;
Added: branches/upstream/libsql-abstract-perl/current/t/90pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/t/90pod.t?rev=43632&op=file
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/t/90pod.t (added)
+++ branches/upstream/libsql-abstract-perl/current/t/90pod.t Fri Sep 4 03:38:06 2009
@@ -1,0 +1,6 @@
+use Test::More;
+
+eval "use Test::Pod 1.14";
+plan skip_all => 'Test::Pod 1.14 required' if $@;
+
+all_pod_files_ok();
Added: branches/upstream/libsql-abstract-perl/current/t/91podcoverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsql-abstract-perl/current/t/91podcoverage.t?rev=43632&op=file
==============================================================================
--- branches/upstream/libsql-abstract-perl/current/t/91podcoverage.t (added)
+++ branches/upstream/libsql-abstract-perl/current/t/91podcoverage.t Fri Sep 4 03:38:06 2009
@@ -1,0 +1,49 @@
+use Test::More;
+
+eval "use Pod::Coverage 0.19";
+plan skip_all => 'Pod::Coverage 0.19 required' if $@;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
+
+plan skip_all => 'set TEST_POD to enable this test'
+ unless ( $ENV{TEST_POD} || -e 'MANIFEST.SKIP' );
+
+my @modules = sort { $a cmp $b } ( Test::Pod::Coverage::all_modules() );
+plan tests => scalar(@modules);
+
+# Since this is about checking documentation, a little documentation
+# of what this is doing might be in order...
+# The exceptions structure below is a hash keyed by the module
+# name. The value for each is a hash, which contains one or more
+# (although currently more than one makes no sense) of the following
+# things:-
+# skip => a true value means this module is not checked
+# ignore => array ref containing list of methods which
+# do not need to be documented.
+my $exceptions = {
+ 'SQL::Abstract' => {
+ ignore => [
+ qw/belch
+ puke/
+ ]
+ },
+ 'SQL::Abstract::Test' => { skip => 1 },
+};
+
+foreach my $module (@modules) {
+ SKIP:
+ {
+ skip "$module - No user visible methods",
+ 1
+ if ( $exceptions->{$module}{skip} );
+
+ # build parms up from ignore list
+ my $parms = {};
+ $parms->{trustme} =
+ [ map { qr/^$_$/ } @{ $exceptions->{$module}{ignore} } ]
+ if exists( $exceptions->{$module}{ignore} );
+
+ # run the test with the potentially modified parm set
+ pod_coverage_ok( $module, $parms, "$module POD coverage" );
+ }
+}
More information about the Pkg-perl-cvs-commits
mailing list