r33342 - in /branches/upstream/libclass-dbi-plugin-retrieveall-perl: ./ current/ current/lib/ current/lib/Class/ current/lib/Class/DBI/ current/lib/Class/DBI/Plugin/ current/t/

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


Author: ryan52-guest
Date: Thu Apr 16 03:16:19 2009
New Revision: 33342

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

Added:
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/Changes
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/MANIFEST
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/MANIFEST.SKIP
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/META.yml
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/Makefile.PL
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/README
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/lib/
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/lib/Class/
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/lib/Class/DBI/
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/lib/Class/DBI/Plugin/
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/lib/Class/DBI/Plugin/RetrieveAll.pm
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/01.t
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/pod-coverage.t
    branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/pod.t

Added: branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/Changes?rev=33342&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/Changes (added)
+++ branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/Changes Thu Apr 16 03:16:19 2009
@@ -1,0 +1,12 @@
+Revision history for Class::DBI::Plugin::RetrieveAll
+
+1.04 Mon Jan 16 11:08:58 UTC 2006
+	- Doc tweaks
+
+1.02 Tue Oct  4 11:14:31 UTC 2005
+	- Added rt.cpan address for bug reports
+
+1.0 Sun Feb  1 2004
+	- first CPAN version
+
+

Added: branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/MANIFEST?rev=33342&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/MANIFEST (added)
+++ branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/MANIFEST Thu Apr 16 03:16:19 2009
@@ -1,0 +1,10 @@
+Changes
+lib/Class/DBI/Plugin/RetrieveAll.pm
+Makefile.PL
+MANIFEST			This list of files
+MANIFEST.SKIP
+META.yml
+README
+t/01.t
+t/pod-coverage.t
+t/pod.t

Added: branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/MANIFEST.SKIP
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/MANIFEST.SKIP?rev=33342&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/MANIFEST.SKIP (added)
+++ branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/MANIFEST.SKIP Thu Apr 16 03:16:19 2009
@@ -1,0 +1,32 @@
+# Avoid version control files.
+\bRCS\b
+\bCVS\b
+,v$
+,B$
+,D$
+\B\.svn\b
+aegis.log$
+\bconfig$
+\bbuild$
+
+# Avoid Makemaker generated and utility files.
+\bMakefile$
+\bblib
+\bMakeMaker-\d
+\bpm_to_blib$
+\bblibdirs$
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\b_build
+
+# Avoid temp and backup files.
+~$
+\.gz$
+\.old$
+\.bak$
+\.swp$
+\.tdy$
+\#$
+\b\.#
+

Added: branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/META.yml?rev=33342&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/META.yml (added)
+++ branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/META.yml Thu Apr 16 03:16:19 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-RetrieveAll
+version:      1.04
+version_from: lib/Class/DBI/Plugin/RetrieveAll.pm
+installdirs:  site
+requires:
+    Class::DBI:                    0.95
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17

Added: branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/Makefile.PL?rev=33342&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/Makefile.PL (added)
+++ branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/Makefile.PL Thu Apr 16 03:16:19 2009
@@ -1,0 +1,8 @@
+use ExtUtils::MakeMaker;
+WriteMakefile(
+	'NAME'      => 'Class::DBI::Plugin::RetrieveAll',
+	'VERSION_FROM' => 'lib/Class/DBI/Plugin/RetrieveAll.pm',
+	'PREREQ_PM' => {
+		'Class::DBI' => '0.95',
+	},
+);

Added: branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/README?rev=33342&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/README (added)
+++ branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/README Thu Apr 16 03:16:19 2009
@@ -1,0 +1,63 @@
+NAME
+    Class::DBI::Plugin::RetrieveAll - more complex retrieve_all() for
+    Class::DBI
+
+SYNOPSIS
+            use base 'Class::DBI';
+            use Class::DBI::Plugin::RetrieveAll;
+
+            my @by_date = My::Class->retrieve_all_sorted_by("date");
+
+            # or
+
+            __PACKAGE__->retrieve_all_sort_field('date');
+
+            my @by_date = My::Class->retrieve_all;
+
+DESCRIPTION
+    This is a simple plugin to a Class::DBI subclass that allows for simple
+    sorting of the results of a retrieve_all().
+
+    There are two main ways to use this.
+
+    Firstly, we create a new method 'retrieve_all_sorted_by' which takes an
+    argument of how to sort.
+
+    We also add a method for 'retrieve_all_sort_field' that sets a default
+    field that any retrieve_all() will use for sorting.
+
+METHODS
+  retrieve_all_sorted_by
+            my @by_date = My::Class->retrieve_all_sorted_by("date");
+
+    This method will be exported into the calling class, and allows for
+    retrieving all the objects of the class, sorted by the given column.
+
+    The argument given will be passed straight through to the database 'as
+    is', and is not checked in any way, so an error here will usually in an
+    error from the database, rather than Class::DBI itself.
+
+    This makes it possible to pass more complex ORDER BY clauses through:
+
+            my @by_date = My::Class->retrieve_all_sorted_by("date DESC, reference_no");
+
+  retrieve_all_sort_field
+      __PACKAGE__->retrieve_all_sort_field('date');
+
+    This method changes the default retrieve_all() in the Class to be
+    auto-sorted by the field given. Again this will be passed through
+    directly, so you can have complex ORDER BY clauses.
+
+AUTHOR
+    Tony Bowden
+
+BUGS and QUERIES
+    Please direct all correspondence regarding this module to:
+    bug-Class-DBI-Plugin-RetrieveAll at rt.cpan.org
+
+COPYRIGHT and LICENSE
+    Copyright (C) 2004-2006 Kasei. All rights reserved.
+
+    This module is free software; you can redistribute it and/or modify it
+    under the same terms as Perl itself.
+

Added: branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/lib/Class/DBI/Plugin/RetrieveAll.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/lib/Class/DBI/Plugin/RetrieveAll.pm?rev=33342&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/lib/Class/DBI/Plugin/RetrieveAll.pm (added)
+++ branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/lib/Class/DBI/Plugin/RetrieveAll.pm Thu Apr 16 03:16:19 2009
@@ -1,0 +1,115 @@
+package Class::DBI::Plugin::RetrieveAll;
+
+our $VERSION = '1.04';
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+Class::DBI::Plugin::RetrieveAll - more complex retrieve_all() for Class::DBI
+
+=head1 SYNOPSIS
+
+	use base 'Class::DBI';
+	use Class::DBI::Plugin::RetrieveAll;
+
+	my @by_date = My::Class->retrieve_all_sorted_by("date");
+
+	# or
+
+	__PACKAGE__->retrieve_all_sort_field('date');
+
+	my @by_date = My::Class->retrieve_all;
+
+=head1 DESCRIPTION
+
+This is a simple plugin to a Class::DBI subclass that allows for simple
+sorting of the results of a retrieve_all(). 
+
+There are two main ways to use this.  
+
+Firstly, we create a new method 'retrieve_all_sorted_by' which takes an
+argument of how to sort.
+
+We also add a method for 'retrieve_all_sort_field' that sets a default
+field that any retrieve_all() will use for sorting.
+
+=head1 METHODS
+
+=head2 retrieve_all_sorted_by
+
+	my @by_date = My::Class->retrieve_all_sorted_by("date");
+
+This method will be exported into the calling class, and allows for
+retrieving all the objects of the class, sorted by the given column.
+
+The argument given will be passed straight through to the database 'as
+is', and is not checked in any way, so an error here will usually
+in an error from the database, rather than Class::DBI itself. 
+
+This makes it possible to pass more complex ORDER BY clauses through:
+
+	my @by_date = My::Class->retrieve_all_sorted_by("date DESC, reference_no");
+
+=head2 retrieve_all_sort_field
+
+  __PACKAGE__->retrieve_all_sort_field('date');
+
+This method changes the default retrieve_all() in the Class to be
+auto-sorted by the field given. Again this will be passed through
+directly, so you can have complex ORDER BY clauses. 
+
+=cut
+
+sub import {
+	my $caller = caller();
+	no strict 'refs';
+
+	$caller->set_sql(retrieve_all_sorted => <<'');
+		SELECT __ESSENTIAL__
+		FROM __TABLE__
+		ORDER BY %s
+
+	*{"$caller\::retrieve_all_sorted_by"} = sub {
+		my ($class, $order_by) = @_;
+		return $class->sth_to_objects($class->sql_retrieve_all_sorted($order_by));
+	};
+
+	$caller->mk_classdata('__plugin_retall_sortfield');
+
+	*{"$caller\::retrieve_all_sort_field"} = sub {
+		my ($class, $field) = @_;
+		$class->__plugin_retall_sortfield($field);
+	};
+
+	# I hate that SUPER means *my* SUPER *now* - not $class->SUPER then
+	my $super = $caller->can('retrieve_all');
+	*{"$caller\::retrieve_all"} = sub {
+		my $class = shift;
+		my $field = $class->__plugin_retall_sortfield 
+			or return $super->($class);
+		return $class->retrieve_all_sorted_by($field);
+	};
+}
+
+=head1 AUTHOR
+
+Tony Bowden
+
+=head1 BUGS and QUERIES
+
+Please direct all correspondence regarding this module to:
+  bug-Class-DBI-Plugin-RetrieveAll at rt.cpan.org
+
+=head1 COPYRIGHT and LICENSE
+
+Copyright (C) 2004-2006 Kasei. All rights reserved.
+
+This module is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
+

Added: branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/01.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/01.t?rev=33342&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/01.t (added)
+++ branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/01.t Thu Apr 16 03:16:19 2009
@@ -1,0 +1,79 @@
+use strict;
+
+use Test::More;
+
+BEGIN {
+	eval "use DBD::SQLite";
+	plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 4);
+}
+
+package My::Film;
+
+use base 'Class::DBI';
+use Class::DBI::Plugin::RetrieveAll;
+
+use File::Temp qw/tempfile/;
+my (undef, $DB) = tempfile();
+my @DSN = ("dbi:SQLite:dbname=$DB", '', '', { AutoCommit => 1 });
+
+END { unlink $DB if -e $DB }
+
+__PACKAGE__->set_db(Main => @DSN);
+__PACKAGE__->table('Movies');
+__PACKAGE__->columns(All => qw/id title year/);
+
+sub CONSTRUCT {
+	shift->db_Main->do(
+		qq{
+     CREATE TABLE Movies (
+        id     INTEGER PRIMARY KEY,
+        title  VARCHAR(255),
+        year   INTEGER
+     )
+	}
+	);
+}
+
+package main;
+
+My::Film->CONSTRUCT;
+
+my %films = (
+	Veronique => 1991,
+	Red       => 1994,
+	White     => 1994,
+	Blue      => 1993,
+	Dekalog   => 1988,
+	Hospital  => 1976,
+	Heaven    => 2002,
+);
+
+while (my ($title, $year) = each %films) {
+	My::Film->create({ title => $title, year => $year });
+}
+
+{
+	my @films = My::Film->retrieve_all;
+	is @films, 7, "Got 7 films";
+}
+
+{
+	my @films = My::Film->retrieve_all_sorted_by('title');
+	is_deeply [ map $_->title, @films ],
+		[qw/Blue Dekalog Heaven Hospital Red Veronique White/], "Sorted by title";
+}
+
+{
+	my @films = My::Film->retrieve_all_sorted_by('year, title DESC');
+	is_deeply [ map $_->title, @films ],
+		[qw/Hospital Dekalog Veronique Blue White Red Heaven/], "Compound sort";
+}
+
+
+My::Film->retrieve_all_sort_field('title');
+
+{
+	my @films = My::Film->retrieve_all;
+	is_deeply [ map $_->title, @films ],
+		[qw/Blue Dekalog Heaven Hospital Red Veronique White/], "Sorted by title";
+}

Added: branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/pod-coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/pod-coverage.t?rev=33342&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/pod-coverage.t (added)
+++ branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/pod-coverage.t Thu Apr 16 03:16:19 2009
@@ -1,0 +1,4 @@
+use Test::More;
+eval "use Test::Pod::Coverage 1.00";
+plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@;
+all_pod_coverage_ok();

Added: branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/pod.t?rev=33342&op=file
==============================================================================
--- branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/pod.t (added)
+++ branches/upstream/libclass-dbi-plugin-retrieveall-perl/current/t/pod.t Thu Apr 16 03:16:19 2009
@@ -1,0 +1,4 @@
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();




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