Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial commit

  • Loading branch information...
commit d218e66f046b50e820a2243485228c0590faf877 0 parents
Tatsuhiko Miyagawa authored
5 .gitignore
@@ -0,0 +1,5 @@
+META.yml
+Makefile
+inc/
+pm_to_blib
+*~
2  .shipit
@@ -0,0 +1,2 @@
+steps = FindVersion, ChangeVersion, CheckChangeLog, DistTest, Commit, Tag, MakeDist, UploadCPAN
+git.push_to = origin
4 Changes
@@ -0,0 +1,4 @@
+Revision history for Perl extension AnyEvent::DBI::Abstract
+
+0.01 Sat Jan 2 22:55:53 2010
+ - original version
33 MANIFEST
@@ -0,0 +1,33 @@
+.gitignore
+Changes
+inc/Module/Install.pm
+inc/Module/Install/AuthorTests.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/Include.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/ReadmeFromPod.pm
+inc/Module/Install/Repository.pm
+inc/Module/Install/TestBase.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
+inc/Spiffy.pm
+inc/Test/Base.pm
+inc/Test/Base/Filter.pm
+inc/Test/Builder.pm
+inc/Test/Builder/Module.pm
+inc/Test/More.pm
+inc/Test/Requires.pm
+lib/AnyEvent/DBI/Abstract.pm
+Makefile.PL
+MANIFEST This list of files
+META.yml
+README
+t/00_compile.t
+t/test.t
+xt/perlcritic.t
+xt/pod.t
+xt/podspell.t
+xt/synopsis.t
14 MANIFEST.SKIP
@@ -0,0 +1,14 @@
+\bRCS\b
+\bCVS\b
+\.svn/
+\.git/
+^MANIFEST\.
+^Makefile$
+~$
+\.old$
+^blib/
+^pm_to_blib
+^MakeMaker-\d
+\.gz$
+\.cvsignore
+\.shipit
13 Makefile.PL
@@ -0,0 +1,13 @@
+use inc::Module::Install;
+name 'AnyEvent-DBI-Abstract';
+all_from 'lib/AnyEvent/DBI/Abstract.pm';
+readme_from 'lib/AnyEvent/DBI/Abstract.pm';
+requires 'AnyEvent::DBI';
+requires 'SQL::Abstract';
+build_requires 'Test::More';
+use_test_base;
+test_requires 'Test::Requires';
+auto_include_deps;
+author_tests('xt');
+auto_set_repository;
+WriteAll;
41 README
@@ -0,0 +1,41 @@
+NAME
+ AnyEvent::DBI::Abstract - AnyEvent::DBI + SQL::Abstract
+
+SYNOPSIS
+ use AnyEvent::DBI::Abstract;
+
+ my $dbh = AnyEvent::DBI::Abstract->new($dsn, $user, $pass);
+
+ $dbh->select($table, \@fields, \%where, \@order, sub {
+ my($dbh, $rows, $rv) = @_;
+ # ...
+ });
+
+ $dbh->insert($table, \%fieldvals, sub {
+ my($dbh, undef, $rv) = @_;
+ # ...
+ });
+
+ $dbh->update($table, \%fieldvals, \%where, sub {
+ my($dbh, undef, $rv) = @_;
+ # ...
+ });
+
+ $dbh->delete($table, \%where, sub {
+ my($dbh, undef, $rv) = @_;
+ # ...
+ });
+
+DESCRIPTION
+ AnyEvent::DBI::Abstract is a subclass that has methods to wrap
+ SQL::Abstract methods into "exec". See SQL::Abstract for the parameters
+ to the methods and AnyEvent::DBI for the callback interface.
+
+AUTHOR
+ Tatsuhiko Miyagawa <miyagawa@bulknews.net>
+
+LICENSE
+ This library is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
+SEE ALSO
81 lib/AnyEvent/DBI/Abstract.pm
@@ -0,0 +1,81 @@
+package AnyEvent::DBI::Abstract;
+
+use strict;
+use 5.008_001;
+our $VERSION = '0.01';
+
+use parent qw(AnyEvent::DBI);
+use Carp ();
+use SQL::Abstract;
+no strict 'refs';
+
+sub abstract {
+ my $self = shift;
+ $self->{_DBI_abstract} ||= SQL::Abstract->new;
+}
+
+for my $method (qw( select insert update delete )) {
+ *$method = sub {
+ my($self, @args) = @_;
+ my $cb = pop @args;
+ my($stmt, @bind) = $self->abstract->$method(@args);
+ $self->exec($stmt, @bind, $cb);
+ };
+}
+
+1;
+__END__
+
+=encoding utf-8
+
+=for stopwords
+
+=head1 NAME
+
+AnyEvent::DBI::Abstract - AnyEvent::DBI + SQL::Abstract
+
+=head1 SYNOPSIS
+
+ use AnyEvent::DBI::Abstract;
+
+ my $dbh = AnyEvent::DBI::Abstract->new($dsn, $user, $pass);
+
+ $dbh->select($table, \@fields, \%where, \@order, sub {
+ my($dbh, $rows, $rv) = @_;
+ # ...
+ });
+
+ $dbh->insert($table, \%fieldvals, sub {
+ my($dbh, undef, $rv) = @_;
+ # ...
+ });
+
+ $dbh->update($table, \%fieldvals, \%where, sub {
+ my($dbh, undef, $rv) = @_;
+ # ...
+ });
+
+ $dbh->delete($table, \%where, sub {
+ my($dbh, undef, $rv) = @_;
+ # ...
+ });
+
+=head1 DESCRIPTION
+
+AnyEvent::DBI::Abstract is a subclass that has methods to wrap
+SQL::Abstract methods into C<exec>. See L<SQL::Abstract> for the
+parameters to the methods and L<AnyEvent::DBI> for the callback
+interface.
+
+=head1 AUTHOR
+
+Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>
+
+=head1 LICENSE
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+=cut
4 t/00_compile.t
@@ -0,0 +1,4 @@
+use strict;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'AnyEvent::DBI::Abstract' }
31 t/test.t
@@ -0,0 +1,31 @@
+use Test::More;
+use Test::Requires qw(DBD::SQLite);
+use AnyEvent::DBI::Abstract;
+
+sub sync(&;&) {
+ my $block = shift;
+ my $cb = shift;
+ my $cv = AE::cv;
+ $cv->cb(sub { $cb->($_[0]->recv) }) if $cb;
+ $block->($cv);
+ $cv->recv;
+}
+
+my $dbh = AnyEvent::DBI::Abstract->new("dbi:SQLite:dbname=t/test.db", "", "");
+sync { $dbh->exec("create table foo (id integer, foo text)", @_) };
+
+sync { $dbh->select("foo", @_) } sub {
+ my($dbh, $rows, $rv) = @_;
+ is_deeply $rows, [];
+};
+
+sync { $dbh->insert("foo", { id => 1, foo => "value" }, @_) };
+
+sync { $dbh->select("foo", @_) } sub {
+ my($dbh, $rows, $rv) = @_;
+ is_deeply $rows, [ [ 1, "value" ] ];
+};
+
+done_testing;
+
+END { unlink "t/test.db" }
5 xt/perlcritic.t
@@ -0,0 +1,5 @@
+use strict;
+use Test::More;
+eval q{ use Test::Perl::Critic };
+plan skip_all => "Test::Perl::Critic is not installed." if $@;
+all_critic_ok("lib");
4 xt/pod.t
@@ -0,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();
9 xt/podspell.t
@@ -0,0 +1,9 @@
+use Test::More;
+eval q{ use Test::Spelling };
+plan skip_all => "Test::Spelling is not installed." if $@;
+add_stopwords(<DATA>);
+set_spell_cmd("aspell -l en list");
+all_pod_files_spelling_ok('lib');
+__DATA__
+Tatsuhiko
+Miyagawa
4 xt/synopsis.t
@@ -0,0 +1,4 @@
+use Test::More;
+eval "use Test::Synopsis";
+plan skip_all => "Test::Synopsis required" if $@;
+all_synopsis_ok();
Please sign in to comment.
Something went wrong with that request. Please try again.