r33334 - in /branches/upstream/libclass-dbi-plugin-perl: ./ current/ current/Changes current/MANIFEST current/META.yml current/Makefile.PL current/Plugin.pm current/README current/t/ current/t/01-require.t current/t/02-select.t

ryan52-guest at users.alioth.debian.org ryan52-guest at users.alioth.debian.org
Thu Apr 16 03:14:17 UTC 2009


Author: ryan52-guest
Date: Thu Apr 16 03:14:12 2009
New Revision: 33334

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=33334
Log:
[svn-inject] Installing original source of libclass-dbi-plugin-perl

Added:
    branches/upstream/libclass-dbi-plugin-perl/
    branches/upstream/libclass-dbi-plugin-perl/current/
    branches/upstream/libclass-dbi-plugin-perl/current/Changes
    branches/upstream/libclass-dbi-plugin-perl/current/MANIFEST
    branches/upstream/libclass-dbi-plugin-perl/current/META.yml
    branches/upstream/libclass-dbi-plugin-perl/current/Makefile.PL
    branches/upstream/libclass-dbi-plugin-perl/current/Plugin.pm
    branches/upstream/libclass-dbi-plugin-perl/current/README
    branches/upstream/libclass-dbi-plugin-perl/current/t/
    branches/upstream/libclass-dbi-plugin-perl/current/t/01-require.t
    branches/upstream/libclass-dbi-plugin-perl/current/t/02-select.t

Added: branches/upstream/libclass-dbi-plugin-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-perl/current/Changes?rev=33334&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-perl/current/Changes (added)
+++ branches/upstream/libclass-dbi-plugin-perl/current/Changes Thu Apr 16 03:14:12 2009
@@ -1,0 +1,13 @@
+Revision history for Perl extension Class::DBI::Plugin.
+
+0.03  Fri Jul 23 16:47:00
+	- bugfix in Makefile.PL: prereq lacked version number
+
+0.02  Mon Jul  5 22:25:00 2004
+	- added note in README that full tests need both DBD::SQLite and
+	  SQL::Abstract
+
+0.01  Sat Jul  3 18:06:37 2004
+	- original version; created by h2xs 1.22 with options
+		-XAn Class::DBI::Plugin -b 5.6.0
+

Added: branches/upstream/libclass-dbi-plugin-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-perl/current/MANIFEST?rev=33334&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-perl/current/MANIFEST (added)
+++ branches/upstream/libclass-dbi-plugin-perl/current/MANIFEST Thu Apr 16 03:14:12 2009
@@ -1,0 +1,8 @@
+Changes
+Makefile.PL
+MANIFEST
+Plugin.pm
+README
+t/01-require.t
+t/02-select.t
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libclass-dbi-plugin-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-perl/current/META.yml?rev=33334&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-perl/current/META.yml (added)
+++ branches/upstream/libclass-dbi-plugin-perl/current/META.yml Thu Apr 16 03:14:12 2009
@@ -1,0 +1,11 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         Class-DBI-Plugin
+version:      0.03
+version_from: Plugin.pm
+installdirs:  site
+requires:
+    Class::DBI:                    0.9
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17

Added: branches/upstream/libclass-dbi-plugin-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-perl/current/Makefile.PL?rev=33334&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-perl/current/Makefile.PL (added)
+++ branches/upstream/libclass-dbi-plugin-perl/current/Makefile.PL Thu Apr 16 03:14:12 2009
@@ -1,0 +1,11 @@
+use 5.006;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME              => 'Class::DBI::Plugin',
+    VERSION_FROM      => 'Plugin.pm',
+    PREREQ_PM         => { 'Class::DBI' => 0.90 },
+    ($] >= 5.005 ?
+      (ABSTRACT_FROM  => 'Plugin.pm',
+       AUTHOR         => 'Jean-Christophe Zeus <mail at jczeus.com>') : ()),
+);

Added: branches/upstream/libclass-dbi-plugin-perl/current/Plugin.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-perl/current/Plugin.pm?rev=33334&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-perl/current/Plugin.pm (added)
+++ branches/upstream/libclass-dbi-plugin-perl/current/Plugin.pm Thu Apr 16 03:14:12 2009
@@ -1,0 +1,117 @@
+package Class::DBI::Plugin;
+
+use 5.006;
+use strict;
+use attributes ();
+
+our $VERSION = 0.03;
+
+# Code stolen from Simon Cozens (Maypole)
+our %remember;
+sub MODIFY_CODE_ATTRIBUTES { $remember{ $_[1] } = $_[2]; () }
+sub FETCH_CODE_ATTRIBUTES  { $remember{ $_[1] } }
+
+sub import
+{
+	my $class  = shift;
+	my $caller = caller;
+	no strict 'refs';
+	for my $symname ( keys %{ "$class\::" } ) {
+		local *sym = ${ "$class\::" }{ $symname };
+		next unless defined &sym; # We're only in it for the subroutines
+		&sym( $caller ), next
+			if $symname eq 'init';
+		*{ "$caller\::$symname" } = \&sym
+			if grep { defined( $_ ) and $_ eq 'Plugged' } attributes::get( \&sym );
+	}
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Class::DBI::Plugin - Abstract base class for Class::DBI plugins
+
+=head1 SYNOPSIS
+
+  use base 'Class::DBI::Plugin';
+  
+  sub init {
+    my $class = shift;
+    $class->set_sql( statement_name => ... );
+    $class->add_trigger( ... );
+    $class->columns( TEMP => ... );
+  }
+  
+  sub method_name : Plugged {
+    my $class = shift;
+    $class->sql_statement_name( ... );
+  }
+
+  sub this_method_is_not_exported {}
+
+=head1 DESCRIPTION
+
+Class::DBI::Plugin is an abstract base class for Class::DBI plugins. Its
+purpose is to make writing plugins easier. Writers of plugins should be able
+to concentrate on the functionality their module provides, instead of having
+to deal with the symbol table hackery involved when writing a plugin
+module.
+Only three things must be remembered:
+
+=over
+
+=item 1
+
+All methods which are to exported are given the "Plugged" attribute. All other
+methods are not exported to the plugged-in class.
+
+=item 2
+
+Method calls which are to be sent to the plugged-in class are put in the
+init() method. Examples of these are set_sql(), add_trigger() and so on.
+
+=item 3
+
+The class parameter for the init() method and the "Plugged" methods is the
+plugged-in class, not the plugin class.
+
+=back
+
+=head1 CAVEATS
+
+So far this module only "sees" methods in the plugin module itself. If there
+is a class between the base class and the plugin class in the inheritance
+hierarchy, methods of this class will not be found. In other words, inherited
+methods will not be found. If requested, I will implement this behaviour.
+
+=head1 TODO
+
+It may be useful for plugin users to be able to choose only the plugin methods
+they are interested in, if there are more than one. This is not implemented yet.
+
+=head1 SEE ALSO
+
+=over
+
+=item *
+
+Class::DBI
+
+=back
+
+=head1 AUTHOR
+
+Jean-Christophe Zeus, E<lt>mail at jczeus.comE<gt> with some help from Simon
+Cozens. Many thanks to Mark Addison for the idea with the init() method, and
+many thanks to Steven Quinney for the idea with the subroutine attributes.
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2004 by Jean-Christophe Zeus
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself. 
+
+=cut

Added: branches/upstream/libclass-dbi-plugin-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-perl/current/README?rev=33334&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-perl/current/README (added)
+++ branches/upstream/libclass-dbi-plugin-perl/current/README Thu Apr 16 03:14:12 2009
@@ -1,0 +1,84 @@
+Class/DBI/Plugin version 0.01
+=============================
+
+INSTALLATION
+
+To install this module type the following:
+
+   perl Makefile.PL
+   make
+   make test
+   make install
+
+Note that "make test" only runs a "live" example if both DBD::SQLite and
+SQL::Abstract are installed.
+
+DEPENDENCIES
+
+This module requires these other modules and libraries:
+
+  Class::DBI
+
+SYNOPSIS
+         use base 'Class::DBI::Plugin';
+
+         sub init {
+           my $class = shift;
+           $class->set_sql( statement_name => ... );
+           $class->add_trigger( ... );
+           $class->columns( TEMP => ... );
+         }
+
+         sub method_name : Plugged {
+           my $class = shift;
+           $class->sql_statement_name( ... );
+         }
+
+         sub this_method_is_not_exported {}
+
+DESCRIPTION
+       Class::DBI::Plugin is an abstract base class for Class::DBI plugins.
+       Its purpose is to make writing plugins easier. Writers of plugins
+       should be able to concentrate on the functionality their module pro-
+       vides, instead of having to deal with the symbol table hackery involved
+       when writing a plugin module.  Only three things must be remembered:
+
+       1   All methods which are to exported are given the "Plugged"
+           attribute. All other methods are not exported to the plugged-in
+           class.
+
+       2   Method calls which are to be sent to the plugged-in class are put
+           in the init() method. Examples of these are set_sql(), add_trig-
+           ger() and so on.
+
+       3   The class parameter for the init() method and the "Plugged" methods
+           is the plugged-in class, not the plugin class.
+
+CAVEATS
+       So far this module only "sees" methods in the plugin module itself. If
+       there is a class between the base class and the plugin class in the
+       inheritance hierarchy, methods of this class will not be found. In
+       other words, inherited methods will not be found. If requested, I will
+       implement this behaviour.
+
+TODO
+       It may be useful for plugin users to be able to choose only the plugin
+       methods they are interested in, if there are more than one. This is not
+       implemented yet.
+
+SEE ALSO
+       o   Class::DBI
+
+AUTHOR
+       Jean-Christophe Zeus, <mail at jczeus.com> with some help from Simon Coz-
+       ens. Many thanks to Mark Addison for the idea with the init() method,
+       and many thanks to Steven Quinney for the idea with the subroutine
+       attributes.
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2004 Jean-Christophe Zeus
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself. 
+

Added: branches/upstream/libclass-dbi-plugin-perl/current/t/01-require.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-perl/current/t/01-require.t?rev=33334&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-perl/current/t/01-require.t (added)
+++ branches/upstream/libclass-dbi-plugin-perl/current/t/01-require.t Thu Apr 16 03:14:12 2009
@@ -1,0 +1,5 @@
+use strict;
+use Test::More tests => 1;
+
+require_ok 'Class::DBI::Plugin';
+

Added: branches/upstream/libclass-dbi-plugin-perl/current/t/02-select.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-perl/current/t/02-select.t?rev=33334&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-perl/current/t/02-select.t (added)
+++ branches/upstream/libclass-dbi-plugin-perl/current/t/02-select.t Thu Apr 16 03:14:12 2009
@@ -1,0 +1,55 @@
+use strict;
+use Test::More;
+
+BEGIN {
+	eval 'use DBD::SQLite; use SQL::Abstract';
+	plan $@
+		? ( skip_all => 'needs DBD::SQLite and SQL::Abstract for testing' )
+		: ( tests => 1 );
+}
+
+use DBI;
+
+my $db = 't/testdb';
+my @dsn = ( "dbi:SQLite:dbname=$db", "", "", { autoCommit => 1 } );
+DBI->connect( @dsn)->do( <<"" );
+CREATE TABLE music
+( id INTEGER NOT NULL PRIMARY KEY
+, title VARCHAR(32)
+)
+
+{
+	package Class::DBI::Plugin::AbstractCount;
+	use base 'Class::DBI::Plugin';
+	use SQL::Abstract;
+	sub init {
+		$_[0]->set_sql( count_search_where => "SELECT COUNT(*) FROM __TABLE__ %s" );
+	}
+	sub count_search_where : Plugged {
+		my $class = shift;
+		my ( $phrase, @bind ) = SQL::Abstract->new()->where( { @_ } );
+		$class->sql_count_search_where( $phrase )->select_val( @bind );
+	}
+}
+
+{
+	package Music;
+	use base qw( Class::DBI );
+	__PACKAGE__->set_db( Main => @dsn );
+	__PACKAGE__->table( 'music' );
+	__PACKAGE__->columns( Primary => qw( id ) );
+	__PACKAGE__->columns( All => qw( title ) );
+	Class::DBI::Plugin::AbstractCount->import;
+}
+
+for my $i ( 1 .. 50 ) {
+	Music->create(
+	{ title => "title $i"
+	});
+}
+
+my $count = Music->count_search_where( title => [ 'title 10', 'title 20' ] );
+is $count, 2, "count is 2";
+
+END { unlink $db if -e $db }
+




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