r64948 - in /branches/upstream/libdancer-plugin-database-perl: ./ current/ current/lib/ current/lib/Dancer/ current/lib/Dancer/Plugin/ current/t/ current/t/lib/

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Wed Nov 17 05:35:09 UTC 2010


Author: dmn
Date: Wed Nov 17 05:34:50 2010
New Revision: 64948

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=64948
Log:
[svn-inject] Installing original source of libdancer-plugin-database-perl (0.11)

Added:
    branches/upstream/libdancer-plugin-database-perl/
    branches/upstream/libdancer-plugin-database-perl/current/
    branches/upstream/libdancer-plugin-database-perl/current/Changes
    branches/upstream/libdancer-plugin-database-perl/current/MANIFEST
    branches/upstream/libdancer-plugin-database-perl/current/META.yml
    branches/upstream/libdancer-plugin-database-perl/current/Makefile.PL
    branches/upstream/libdancer-plugin-database-perl/current/README
    branches/upstream/libdancer-plugin-database-perl/current/lib/
    branches/upstream/libdancer-plugin-database-perl/current/lib/Dancer/
    branches/upstream/libdancer-plugin-database-perl/current/lib/Dancer/Plugin/
    branches/upstream/libdancer-plugin-database-perl/current/lib/Dancer/Plugin/Database.pm
    branches/upstream/libdancer-plugin-database-perl/current/t/
    branches/upstream/libdancer-plugin-database-perl/current/t/00-load.t
    branches/upstream/libdancer-plugin-database-perl/current/t/01-basic.t
    branches/upstream/libdancer-plugin-database-perl/current/t/lib/
    branches/upstream/libdancer-plugin-database-perl/current/t/lib/TestApp.pm
    branches/upstream/libdancer-plugin-database-perl/current/t/manifest.t
    branches/upstream/libdancer-plugin-database-perl/current/t/pod-coverage.t
    branches/upstream/libdancer-plugin-database-perl/current/t/pod.t

Added: branches/upstream/libdancer-plugin-database-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-plugin-database-perl/current/Changes?rev=64948&op=file
==============================================================================
--- branches/upstream/libdancer-plugin-database-perl/current/Changes (added)
+++ branches/upstream/libdancer-plugin-database-perl/current/Changes Wed Nov 17 05:34:50 2010
@@ -1,0 +1,55 @@
+Revision history for Dancer-Plugin-Database
+
+0.11  2010-11-09 (CoD Black Ops day!)
+        - Bugfix: pass connection settings when reconnecting, too.
+
+0.10  2010-10-30
+        - Add some proper tests [Franck Cuny]
+
+0.09    2010-09-28
+        - Allow definition of multiple connections, and accept a param to the
+          database() keyword to specify which connection you need a handle for.
+          This was released as 0.08_01 for testing.
+
+0.08    2010-09-14
+        - Bugfix - make SQLite DWIMmery from previous version actually work.
+
+0.07    2010-09-06
+        - Extra params in DSN (database, host, port) should be separated with
+          semi-colons, not colons.  Thanks to Steve Atkins for reporting this.
+        - Documentation update to reflect use of $dbh->ping
+        - If connecting to SQLite, which requires 'dbname' rather than
+          'database', provide 'dbname' instead, so it will Just Work
+
+0.06    2010-06-15
+        - Stupid typo fix in documentation for features added in 0.05.  I wish
+          I'd spotted this mistake before releasing 0.05, rather than just
+          after!
+
+0.05    2010-06-15
+        - Allow parameters to be passed to DBI->connect call (e.g. RaiseError),
+          and support providing a set of statements to execute upon connection.
+          Thanks to Igor Bujna for providing this feature!
+
+0.04    2010-05-20
+        - If DBD driver does not implement ping(), perform our own connection
+          check by performing a simple query.  This will check that the DB
+          connection is still alive, and avoid needless re-connects, which are
+          expensive.  Also seems to fix a problem Tadzik saw with a warning from
+          DBD::SQLite when the old handle was thrown away.
+
+0.03    2010-05-17
+        - Fix warning where $last_connection_check was initially undefined but
+          used in numeric comparison.  Thanks to Tadzik for reporting.
+
+0.02    2010-04-18
+        Documentation fixes, thanks to "mrpants" on Github:
+        - Plugin names in config.yml are case-sensitive for current CPAN
+          releases of Dancer; my commit fdc3f3 makes it case-insenitive, but
+          that hasn't hit CPAN yet, so people using CPAN releases could be
+          confused
+        - stray trailing single-quote in example config
+
+0.01    2010-04-14
+        Initial version developed.
+

Added: branches/upstream/libdancer-plugin-database-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-plugin-database-perl/current/MANIFEST?rev=64948&op=file
==============================================================================
--- branches/upstream/libdancer-plugin-database-perl/current/MANIFEST (added)
+++ branches/upstream/libdancer-plugin-database-perl/current/MANIFEST Wed Nov 17 05:34:50 2010
@@ -1,0 +1,12 @@
+Changes
+MANIFEST
+Makefile.PL
+README
+lib/Dancer/Plugin/Database.pm
+t/00-load.t
+t/01-basic.t
+t/manifest.t
+t/pod-coverage.t
+t/pod.t
+t/lib/TestApp.pm
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libdancer-plugin-database-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-plugin-database-perl/current/META.yml?rev=64948&op=file
==============================================================================
--- branches/upstream/libdancer-plugin-database-perl/current/META.yml (added)
+++ branches/upstream/libdancer-plugin-database-perl/current/META.yml Wed Nov 17 05:34:50 2010
@@ -1,0 +1,24 @@
+--- #YAML:1.0
+name:               Dancer-Plugin-Database
+version:            0.11
+abstract:           easy database connections for Dancer applications
+author:
+    - David Precious <davidp at preshweb.co.uk>
+license:            perl
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    Dancer:      1.175
+    DBI:         0
+    Test::More:  0
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.56
+meta-spec:
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Added: branches/upstream/libdancer-plugin-database-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-plugin-database-perl/current/Makefile.PL?rev=64948&op=file
==============================================================================
--- branches/upstream/libdancer-plugin-database-perl/current/Makefile.PL (added)
+++ branches/upstream/libdancer-plugin-database-perl/current/Makefile.PL Wed Nov 17 05:34:50 2010
@@ -1,0 +1,21 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME                => 'Dancer::Plugin::Database',
+    AUTHOR              => q{David Precious <davidp at preshweb.co.uk>},
+    VERSION_FROM        => 'lib/Dancer/Plugin/Database.pm',
+    ABSTRACT_FROM       => 'lib/Dancer/Plugin/Database.pm',
+    ($ExtUtils::MakeMaker::VERSION >= 6.3002
+      ? ('LICENSE'=> 'perl')
+      : ()),
+    PL_FILES            => {},
+    PREREQ_PM => {
+        'Test::More' => 0,
+        'Dancer'     => 1.175,
+        'DBI'        => 0,
+    },
+    dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+    clean               => { FILES => 'Dancer-Plugin-Database-*' },
+);

Added: branches/upstream/libdancer-plugin-database-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-plugin-database-perl/current/README?rev=64948&op=file
==============================================================================
--- branches/upstream/libdancer-plugin-database-perl/current/README (added)
+++ branches/upstream/libdancer-plugin-database-perl/current/README Wed Nov 17 05:34:50 2010
@@ -1,0 +1,47 @@
+Dancer-Plugin-Database
+
+A plugin for Dancer applications, providing easy database connection handling.
+
+See http://www.perldancer.org/ for details on Dancer.
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+	perl Makefile.PL
+	make
+	make test
+	make install
+
+SUPPORT AND DOCUMENTATION
+
+After installing, you can find documentation for this module with the
+perldoc command.
+
+    perldoc Dancer::Plugin::Database
+
+You can also look for information at:
+
+    RT, CPAN's request tracker
+        http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dancer-Plugin-Database
+
+    AnnoCPAN, Annotated CPAN documentation
+        http://annocpan.org/dist/Dancer-Plugin-Database
+
+    CPAN Ratings
+        http://cpanratings.perl.org/d/Dancer-Plugin-Database
+
+    Search CPAN
+        http://search.cpan.org/dist/Dancer-Plugin-Database/
+
+
+LICENSE AND COPYRIGHT
+
+Copyright (C) 2010 David Precious
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of either: the GNU General Public License as published
+by the Free Software Foundation; or the Artistic License.
+
+See http://dev.perl.org/licenses/ for more information.
+

Added: branches/upstream/libdancer-plugin-database-perl/current/lib/Dancer/Plugin/Database.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-plugin-database-perl/current/lib/Dancer/Plugin/Database.pm?rev=64948&op=file
==============================================================================
--- branches/upstream/libdancer-plugin-database-perl/current/lib/Dancer/Plugin/Database.pm (added)
+++ branches/upstream/libdancer-plugin-database-perl/current/lib/Dancer/Plugin/Database.pm Wed Nov 17 05:34:50 2010
@@ -1,0 +1,370 @@
+package Dancer::Plugin::Database;
+
+use strict;
+use Dancer::Plugin;
+use DBI;
+
+=head1 NAME
+
+Dancer::Plugin::Database - easy database connections for Dancer applications
+
+=cut
+
+our $VERSION = '0.11';
+
+my $settings = undef;
+
+sub _load_db_settings { $settings = plugin_setting; }
+
+my %handles;
+# Hashref used as key for default handle, so we don't have a magic value that
+# the user could use for one of their connection names and cause problems
+# (Kudos to Igor Bujna for the idea)
+my $def_handle = {};
+
+register database => sub {
+    my $name = shift;
+
+    _load_db_settings() if (!$settings);
+    
+    my $handle = defined($name) ? $handles{$name} : $def_handle;
+    my $settings = _get_settings($name);
+
+    if ($handle->{dbh}) {
+        if (time - $handle->{last_connection_check}
+            < $settings->{connection_check_threshold}) {
+            return $handle->{dbh};
+        } else {
+            if (_check_connection($handle->{dbh})) {
+                $handle->{last_connection_check} = time;
+                return $handle->{dbh};
+            } else {
+                Dancer::Logger::debug(
+                    "Database connection went away, reconnecting"
+                );
+                if ($handle->{dbh}) { $handle->{dbh}->disconnect; }
+                return $handle->{dbh}= _get_connection($settings);
+            }
+        }
+    } else {
+        # Get a new connection
+        if (!$settings) {
+            Dancer::Logger::error(
+                "No DB settings named $name, so cannot connect"
+            );
+            return;
+        }
+        if ($handle->{dbh} = _get_connection($settings)) {
+            $handle->{last_connection_check} = time;
+            return $handle->{dbh};
+        } else {
+            return;
+        }
+    }
+};
+
+register_plugin;
+
+# Given the settings to use, try to get a database connection
+sub _get_connection {
+    my $settings = shift;
+
+    # Assemble the DSN:
+    my $dsn;
+    if ($settings->{dsn}) {
+        $dsn = $settings->{dsn};
+    } else {
+        $dsn = "dbi:" . $settings->{driver};
+        my @extra_args;
+
+        # DBD::SQLite wants 'dbname', not 'database', so special-case this
+        # (DBI's documentation recommends that DBD::* modules should understand
+        # 'database', but older versions of DBD::SQLite didn't; let's make 
+        # things easier for our users by handling this for them):
+        # (DBD::SQLite will support 'database', too, as of 1.32 when it's
+        # released)
+        if ($settings->{driver} eq 'SQLite' 
+            && $settings->{database} && !$settings->{dbname}) {
+            $settings->{dbname} = delete $settings->{database};
+        }
+
+        for (qw(database dbname host port)) {
+            if (exists $settings->{$_}) {
+                push @extra_args, $_ . "=" . $settings->{$_};
+            }
+        }
+        $dsn .= ':' . join(';', @extra_args) if @extra_args;
+    }
+
+    my $dbh = DBI->connect($dsn, 
+        $settings->{username}, $settings->{password}, $settings->{dbi_params}
+    );
+
+    if (!$dbh) {
+        Dancer::Logger::error(
+            "Database connection failed - " . $DBI::errstr
+        );
+    } elsif (exists $settings->{on_connect_do}) {
+        for (@{ $settings->{on_connect_do} }) {
+            $dbh->do($_) or Dancer::Logger::error(
+                "Failed to perform on-connect command $_"
+            );
+        }
+    }
+
+    return $dbh;
+}
+
+
+
+# Check the connection is alive
+sub _check_connection {
+    my $dbh = shift;
+    return unless $dbh;
+    if (my $result = $dbh->ping) {
+        if (int($result)) {
+            # DB driver itself claims all is OK, trust it:
+            return 1;
+        } else {
+            # It was "0 but true", meaning the default DBI ping implementation
+            # Implement our own basic check, by performing a real simple query.
+            my $ok;
+            eval {
+                $ok = $dbh->do('select 1');
+            };
+            return $ok;
+        }
+    } else {
+        return;
+    }
+}
+
+sub _get_settings {
+    my $name = shift;
+    my $return_settings;
+
+    # If no name given, just return the default settings
+    # (Take a copy and remove the connections key, so we have only the main
+    # connection details)
+    if (!defined $name) {
+        $return_settings = { %$settings };
+    } else {
+        # If there are no named connections in the config, bail now:
+        return unless exists $settings->{connections};
+
+
+        # OK, find a matching config for this name:
+        if (my $settings = $settings->{connections}{$name}) {
+            $return_settings = { %$settings };
+        } else {
+            # OK, didn't match anything
+            Dancer::Logger::error(
+                "Asked for a database handle named '$name' but no matching  "
+               ."connection details found in config"
+            );
+        }
+    }
+    
+    # We should have soemthing to return now; remove any unrelated connections
+    # (only needed if this is the default connection), and make sure we have a
+    # connection_check_threshold, then return what we found
+    delete $return_settings->{connections};
+    $return_settings->{connection_check_threshold} ||= 30;
+    return $return_settings;
+
+}
+
+
+=head1 SYNOPSIS
+
+    use Dancer;
+    use Dancer::Plugin::Database;
+
+    # Calling the database keyword will get you a connected DBI handle:
+    get '/widget/view/:id' => sub {
+        my $sth = database->prepare(
+            'select * from widgets where id = ?',
+        );
+        $sth->execute(params->{id});
+        template 'display_widget', { widget => $sth->fetchrow_hashref };
+    };
+
+    dance;
+
+Database connection details are read from your Dancer application config - see
+below.
+
+
+=head1 DESCRIPTION
+
+Provides an easy way to obtain a connected DBI database handle by simply calling
+the database keyword within your L<Dancer> application.
+
+Takes care of ensuring that the database handle is still connected and valid.
+If the handle was last asked for more than C<connection_check_threshold> seconds
+ago, it will check that the connection is still alive, using either the 
+C<< $dbh->ping >> method if the DBD driver supports it, or performing a simple
+no-op query against the database if not.  If the connection has gone away, a new
+connection will be obtained and returned.  This avoids any problems for
+a long-running script where the connection to the database might go away.
+
+=head1 CONFIGURATION
+
+Connection details will be taken from your Dancer application config file, and
+should be specified as, for example: 
+
+    plugins:
+        Database:
+            driver: 'mysql'
+            database: 'test'
+            host: 'localhost'
+            username: 'myusername'
+            password: 'mypassword'
+            connectivity-check-threshold: 10
+            dbi_params:
+                RaiseError: 1
+                AutoCommit: 1
+            on_connect_do: ["SET NAMES 'utf8'", "SET CHARACTER SET 'utf8'" ]
+
+The C<connectivity-check-threshold> setting is optional, if not provided, it
+will default to 30 seconds.  If the database keyword was last called more than
+this number of seconds ago, a quick check will be performed to ensure that we
+still have a connection to the database, and will reconnect if not.  This
+handles cases where the database handle hasn't been used for a while and the
+underlying connection has gone away.
+
+The C<dbi_params> setting is also optional, and if specified, should be settings
+which can be passed to C<< DBI->connect >> as its third argument; see the L<DBI>
+documentation for these.
+
+The optional C<on_connect_do> setting is an array of queries which should be
+performed when a connection is established; if given, each query will be
+performed using C<< $dbh->do >>.
+
+If you prefer, you can also supply a pre-crafted DSN using the C<dsn> setting;
+in that case, it will be used as-is, and the driver/database/host settings will 
+be ignored.  This may be useful if you're using some DBI driver which requires 
+a peculiar DSN.
+
+
+=head2 DEFINING MULTIPLE CONNECTIONS
+
+If you need to connect to multiple databases, this is easy - just list them in
+your config under C<connections> as shown below:
+
+    plugins:
+        Database:
+            connections:
+                foo:
+                    driver: "SQLite"
+                    database: "foo.sqlite"
+                bar:
+                    driver: "mysql"
+                    host: "localhost"
+                    ....
+
+Then, you can call the C<database> keyword with the name of the database
+connection you want, for example:
+
+    my $foo_dbh = database('foo');
+    my $bar_dbh = database('bar');
+
+
+
+=head1 GETTING A DATABASE HANDLE
+
+Calling C<database> will return a connected database handle; the first time it is
+called, the plugin will establish a connection to the database, and return a
+reference to the DBI object.  On subsequent calls, the same DBI connection
+object will be returned, unless it has been found to be no longer usable (the
+connection has gone away), in which case a fresh connection will be obtained.
+
+If you have declared named connections as described above in 'DEFINING MULTIPLE
+CONNECTIONS', then calling the database() keyword with the name of the
+connection as specified in the config file will get you a database handle
+connected with those details.
+
+=head1 AUTHOR
+
+David Precious, C<< <davidp at preshweb.co.uk> >>
+
+
+
+=head1 CONTRIBUTING
+
+This module is developed on Github at:
+
+L<http://github.com/bigpresh/Dancer-Plugin-Database>
+
+Feel free to fork the repo and submit pull requests!
+
+
+=head1 ACKNOWLEDGEMENTS
+
+Igor Bujna
+
+Franck Cuny
+
+=head1 BUGS
+
+Please report any bugs or feature requests to C<bug-dancer-plugin-database at rt.cpan.org>, or through
+the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dancer-Plugin-Database>.  I will be notified, and then you'll
+automatically be notified of progress on your bug as I make changes.
+
+
+
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+    perldoc Dancer::Plugin::Database
+
+
+You can also look for information at:
+
+=over 4
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dancer-Plugin-Database>
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/Dancer-Plugin-Database>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/Dancer-Plugin-Database>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/Dancer-Plugin-Database/>
+
+=back
+
+You can find the author on IRC in the channel C<#dancer> on <irc.perl.org>.
+
+
+=head1 LICENSE AND COPYRIGHT
+
+Copyright 2010 David Precious.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of either: the GNU General Public License as published
+by the Free Software Foundation; or the Artistic License.
+
+See http://dev.perl.org/licenses/ for more information.
+
+
+=head1 SEE ALSO
+
+L<Dancer>
+
+L<DBI>
+
+
+
+=cut
+
+1; # End of Dancer::Plugin::Database

Added: branches/upstream/libdancer-plugin-database-perl/current/t/00-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-plugin-database-perl/current/t/00-load.t?rev=64948&op=file
==============================================================================
--- branches/upstream/libdancer-plugin-database-perl/current/t/00-load.t (added)
+++ branches/upstream/libdancer-plugin-database-perl/current/t/00-load.t Wed Nov 17 05:34:50 2010
@@ -1,0 +1,10 @@
+#!perl -T
+
+use Test::More tests => 1;
+
+BEGIN {
+    use_ok( 'Dancer::Plugin::Database' ) || print "Bail out!
+";
+}
+
+diag( "Testing Dancer::Plugin::Database $Dancer::Plugin::Database::VERSION, Perl $], $^X" );

Added: branches/upstream/libdancer-plugin-database-perl/current/t/01-basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-plugin-database-perl/current/t/01-basic.t?rev=64948&op=file
==============================================================================
--- branches/upstream/libdancer-plugin-database-perl/current/t/01-basic.t (added)
+++ branches/upstream/libdancer-plugin-database-perl/current/t/01-basic.t Wed Nov 17 05:34:50 2010
@@ -1,0 +1,35 @@
+use strict;
+use warnings;
+
+use Test::More import => ['!pass'];
+
+use t::lib::TestApp;
+use Dancer ':syntax';
+use Dancer::Test;
+
+eval { require DBD::SQLite };
+if ($@) {
+    plan skip_all => 'DBD::SQLite required to run these tests';
+}
+
+plan tests => 8;
+
+my $dsn = "dbi:SQLite:dbname=:memory:";
+
+setting plugins => { Database => { dsn => $dsn, } };
+
+response_status_is [ GET => '/prepare_db' ], 200, 'db is created';
+
+response_status_is    [ GET => '/' ], 200,   "GET / is found";
+response_content_like [ GET => '/' ], qr/2/, "content looks god for /";
+
+response_status_is [ GET => '/user/1' ], 200, 'GET /user/1 is found';
+
+response_content_like [ GET => '/user/1' ], qr/sukria/,
+  'content looks good for /user/1';
+response_content_like [ GET => '/user/2' ], qr/bigpresh/,
+  "content looks good for /user/2";
+
+response_status_is [ DELETE => '/user/2' ], 200, 'DELETE /user/2 is ok';
+response_content_like [ GET => '/' ], qr/1/, 'content looks good for /';
+

Added: branches/upstream/libdancer-plugin-database-perl/current/t/lib/TestApp.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-plugin-database-perl/current/t/lib/TestApp.pm?rev=64948&op=file
==============================================================================
--- branches/upstream/libdancer-plugin-database-perl/current/t/lib/TestApp.pm (added)
+++ branches/upstream/libdancer-plugin-database-perl/current/t/lib/TestApp.pm Wed Nov 17 05:34:50 2010
@@ -1,0 +1,38 @@
+package t::lib::TestApp;
+
+use Dancer;
+use Dancer::Plugin::Database;
+
+get '/prepare_db' => sub {
+
+    my @sql = (
+        q/create table users (id INTEGER, name VARCHAR(64))/,
+        q/insert into users values (1, 'sukria')/,
+        q/insert into users values (2, 'bigpresh')/,
+    );
+
+    database->do($_) for @sql;
+    'ok';
+};
+
+get '/' => sub {
+    my $sth = database->prepare('select count(*) from users');
+    $sth->execute;
+    my $total_users = $sth->fetch();
+    $total_users->[0];
+};
+
+get '/user/:id' => sub {
+    my $sth = database->prepare('select * from users where id = ?');
+    $sth->execute( params->{id} );
+    my $user = $sth->fetch();
+    $user->[1];
+};
+
+del '/user/:id' => sub {
+    my $sth = database->prepare('delete from users where id = ?');
+    $sth->execute( params->{id} );
+    'ok';
+};
+
+1;

Added: branches/upstream/libdancer-plugin-database-perl/current/t/manifest.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-plugin-database-perl/current/t/manifest.t?rev=64948&op=file
==============================================================================
--- branches/upstream/libdancer-plugin-database-perl/current/t/manifest.t (added)
+++ branches/upstream/libdancer-plugin-database-perl/current/t/manifest.t Wed Nov 17 05:34:50 2010
@@ -1,0 +1,13 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More;
+
+unless ( $ENV{RELEASE_TESTING} ) {
+    plan( skip_all => "Author tests not required for installation" );
+}
+
+eval "use Test::CheckManifest 0.9";
+plan skip_all => "Test::CheckManifest 0.9 required" if $@;
+ok_manifest();

Added: branches/upstream/libdancer-plugin-database-perl/current/t/pod-coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-plugin-database-perl/current/t/pod-coverage.t?rev=64948&op=file
==============================================================================
--- branches/upstream/libdancer-plugin-database-perl/current/t/pod-coverage.t (added)
+++ branches/upstream/libdancer-plugin-database-perl/current/t/pod-coverage.t Wed Nov 17 05:34:50 2010
@@ -1,0 +1,18 @@
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod::Coverage
+my $min_tpc = 1.08;
+eval "use Test::Pod::Coverage $min_tpc";
+plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
+    if $@;
+
+# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
+# but older versions don't recognize some common documentation styles
+my $min_pc = 0.18;
+eval "use Pod::Coverage $min_pc";
+plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
+    if $@;
+
+all_pod_coverage_ok();

Added: branches/upstream/libdancer-plugin-database-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdancer-plugin-database-perl/current/t/pod.t?rev=64948&op=file
==============================================================================
--- branches/upstream/libdancer-plugin-database-perl/current/t/pod.t (added)
+++ branches/upstream/libdancer-plugin-database-perl/current/t/pod.t Wed Nov 17 05:34:50 2010
@@ -1,0 +1,12 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod
+my $min_tp = 1.22;
+eval "use Test::Pod $min_tp";
+plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
+
+all_pod_files_ok();




More information about the Pkg-perl-cvs-commits mailing list