[Catalyst-commits] r7660 - in Catalyst-Controller-REST-DBIC-Item/trunk/0.01: . lib lib/Catalyst lib/Catalyst/Controller lib/Catalyst/Controller/REST lib/Catalyst/Controller/REST/DBIC lib/Catalyst/Helper lib/Catalyst/Helper/Controller lib/Catalyst/Helper/Controller/REST lib/Catalyst/Helper/Controller/REST/DBIC t t/lib t/lib/TestApp t/lib/TestApp/Controller t/lib/TestApp/Model t/lib/TestApp/Schema t/var

jshirley at dev.catalyst.perl.org jshirley at dev.catalyst.perl.org
Wed Apr 30 16:27:03 BST 2008


Author: jshirley
Date: 2008-04-30 16:27:03 +0100 (Wed, 30 Apr 2008)
New Revision: 7660

Added:
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/.cvsignore
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/Changes
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/MANIFEST
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/Makefile.PL
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/README
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Controller/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Controller/REST/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Controller/REST/DBIC/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Controller/REST/DBIC/.Item.pm.swp
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Controller/REST/DBIC/Item.pm
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Helper/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Helper/Controller/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Helper/Controller/REST/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Helper/Controller/REST/DBIC/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Helper/Controller/REST/DBIC/Item.pm
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/.00-load.t.swp
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/00-load.t
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/boilerplate.t
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp.pm
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Controller/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Controller/Book.pm
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Controller/Root.pm
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Model/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Model/Schema.pm
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Schema.pm
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Schema/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Schema/Book.pm
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/pod-coverage.t
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/pod.t
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/var/
   Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/var/Test.db
Log:
New controller base class for speedy REST+DBIC dev

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/.cvsignore
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/.cvsignore	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/.cvsignore	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,10 @@
+blib*
+Makefile
+Makefile.old
+Build
+_build*
+pm_to_blib*
+*.tar.gz
+.lwpcookies
+Catalyst-Controller-REST-DBIC-Item-*
+cover_db

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/Changes
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/Changes	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/Changes	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,5 @@
+Revision history for Catalyst-Controller-REST-DBIC-Item
+
+0.01    Date/time
+        First version, released on an unsuspecting world.
+

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/MANIFEST
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/MANIFEST	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/MANIFEST	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,8 @@
+Changes
+MANIFEST
+Makefile.PL
+README
+lib/Catalyst/Controller/REST/DBIC/Item.pm
+t/00-load.t
+t/pod-coverage.t
+t/pod.t

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/Makefile.PL
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/Makefile.PL	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/Makefile.PL	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,16 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME                => 'Catalyst::Controller::REST::DBIC::Item',
+    AUTHOR              => 'J. Shirley <jshirley at coldhardcode.com>',
+    VERSION_FROM        => 'lib/Catalyst/Controller/REST/DBIC/Item.pm',
+    ABSTRACT_FROM       => 'lib/Catalyst/Controller/REST/DBIC/Item.pm',
+    PL_FILES            => {},
+    PREREQ_PM => {
+        'Test::More' => 0,
+    },
+    dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+    clean               => { FILES => 'Catalyst-Controller-REST-DBIC-Item-*' },
+);

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/README
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/README	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/README	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,52 @@
+Catalyst-Controller-REST-DBIC-Item
+
+The README is used to introduce the module and provide instructions on
+how to install the module, any machine dependencies it may have (for
+example C compilers and installed libraries) and any other information
+that should be provided before the module is installed.
+
+A README file is required for CPAN modules since CPAN extracts the README
+file from a module distribution so that people browsing the archive
+can use it to get an idea of the module's uses. It is usually a good idea
+to provide version information here so that people can decide whether
+fixes for the module are worth downloading.
+
+
+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 Catalyst::Controller::REST::DBIC::Item
+
+You can also look for information at:
+
+    RT, CPAN's request tracker
+        http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Controller-REST-DBIC-Item
+
+    AnnoCPAN, Annotated CPAN documentation
+        http://annocpan.org/dist/Catalyst-Controller-REST-DBIC-Item
+
+    CPAN Ratings
+        http://cpanratings.perl.org/d/Catalyst-Controller-REST-DBIC-Item
+
+    Search CPAN
+        http://search.cpan.org/dist/Catalyst-Controller-REST-DBIC-Item
+
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2008 J. Shirley
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Controller/REST/DBIC/.Item.pm.swp
===================================================================
(Binary files differ)


Property changes on: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Controller/REST/DBIC/.Item.pm.swp
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Controller/REST/DBIC/Item.pm
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Controller/REST/DBIC/Item.pm	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Controller/REST/DBIC/Item.pm	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,178 @@
+package Catalyst::Controller::REST::DBIC::Item;
+
+use warnings;
+use strict;
+
+use base qw/Catalyst::Controller::REST/;
+
+use Carp;
+
+=head1 NAME
+
+Catalyst::Controller::REST::DBIC::Item - Common base class for typical REST
+actions against a DBIx::Class object
+
+=head1 VERSION
+
+Version 0.01
+
+=cut
+
+our $VERSION = '0.01';
+
+=head1 DESCRIPTION
+
+This is a controller base class that is designed to build some conventions
+around integrating REST and DBIC together in a Catalyst application.
+
+The idea of this class is that, in the simplest terms, each item in a REST
+application has one URL to interface with it.  Typically, these objects have a 
+one to one mapping with a backend schema class.  This base class helps to reduce
+the repetition in your REST classes and allow you to focus on just handling
+the individual verbs (GET, PUT, POST, etc)
+
+=head1 SYNOPSIS
+
+    package MyApp::Controller::Person;
+
+    use base 'Catalyst::Controller::REST::DBIC::Item';
+
+    __PACKAGE__->config(
+        # Add REST config
+        'default' => 'text/html'
+        # And, our bindings to DBIC, will use 
+        # $c->model('Schema::Person') effectively.
+        resultset => 'Schema:;Person',
+        # Optional configuration for templates
+        templates => {
+            not_found => 'errors/not_found.tt'
+        }
+    );
+
+    # This operates off of chained, and requires rest_base to be defined
+    
+    sub rest_base : Chained('.') PathPart('person') CaptureArgs(0) { }
+
+    1;
+
+=head1 CONFIGURATION
+
+A list of functions that can be exported.  You can delete this section
+if you don't export anything, such as for a purely object-oriented module.
+
+=head1 GENERATED REST METHODS
+
+=head2 rest_list PathPart('')
+
+=cut
+
+sub list : Chained('rest_base') PathPart('') Args(0) ActionClass('REST') {
+
+}
+
+sub list_GET  { }
+
+=head2 rest_item PathPart('') CaptureArgs(1)
+
+This method is used to handle triggering the single item methods.  Override
+rest_item_GET, rest_item_POST, etc to have custom behavior.
+
+=cut
+
+sub item_base : Chained('rest_base') PathPart('') CaptureArgs(1) {
+    my ( $self, $c, $pk1 ) = @_;
+
+    $c->stash->{rest}->{item} = $self->get_item( $c, $pk1 );
+}
+
+sub item : Chained('item_base') PathPart('') Args(0) ActionClass('REST') {
+    my ( $self, $c ) = @_;
+}
+
+sub item_GET {
+    my ( $self, $c ) = @_;
+    unless ( $c->stash->{rest}->{item} ) {
+        return $self->status_not_found( $c, 
+            message => $c->localize('ITEM_NOT_FOUND') );
+    }
+    return $self->status_ok( $c,
+        entity => $c->stash->{rest}->{item}
+    );
+}
+
+sub get_item {
+    my ( $self, $c, $item ) = @_;
+    if ( my $key = $self->{item_key} ) {
+        return $self->get_rs($c)->find({ $key => $item });
+    } else {            
+        return $self->get_rs($c)->find( $item );
+    }
+}
+
+sub get_rs {
+    my ( $self, $c, $item ) = @_;
+    my $model = $self->{class};
+    my $rs    = $c->model($model);
+    croak "Unable to find DBIC resultset $model, check config"
+        unless $rs;
+    return $rs;
+}
+
+
+=head1 AUTHOR
+
+J. Shirley, C<< <jshirley at coldhardcode.com> >>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to C<bug-catalyst-controller-rest-dbic-item at rt.cpan.org>, or through
+the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Controller-REST-DBIC-Item>.  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 Catalyst::Controller::REST::DBIC::Item
+
+
+You can also look for information at:
+
+=over 4
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Controller-REST-DBIC-Item>
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/Catalyst-Controller-REST-DBIC-Item>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/Catalyst-Controller-REST-DBIC-Item>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/Catalyst-Controller-REST-DBIC-Item>
+
+=back
+
+
+=head1 ACKNOWLEDGEMENTS
+
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2008 Cold Hard Code, LLC, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+
+=cut
+
+1; # End of Catalyst::Controller::REST::DBIC::Item
+
+

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Helper/Controller/REST/DBIC/Item.pm
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Helper/Controller/REST/DBIC/Item.pm	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/lib/Catalyst/Helper/Controller/REST/DBIC/Item.pm	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,86 @@
+package Catalyst::Helper::Controller::REST::DBIC::Item;
+
+use strict;
+
+=head1 NAME
+
+Catalyst::Helper::Controller::REST::DBIC::Item - Helper to create REST controllers
+
+=head1 SYNOPSIS
+
+    $ catalyst.pl myapp
+    $ cd myapp
+    $ script/myapp_create.pl controller Book REST::DBIC::Item Schema::Book
+
+=head1 DESCRIPTION
+
+Helper to create REST Base classes.
+
+=head1 SEE ALSO
+
+L<Catalyst::Action::REST>
+
+L<Catalyst::Model::DBIC::Schema>
+
+=head1 AUTHOR
+
+J. Shirley C<cpan at coldhardcode.com>
+
+=head1 LICENSE
+
+This library is free software . You can redistribute it and/or modify
+it under the same terms as perl itself.
+
+=cut
+
+sub mk_compclass {
+    my ( $self, $helper, $schema_class ) = @_;
+    $helper->{schema_class} = $helper;
+    my $file = $helper->{file};
+    $helper->render_file( 'compclass', $file );
+}
+
+1;
+
+__DATA__
+
+__compclass__
+package [% class %];
+
+use warnings;
+use strict;
+
+use base 'Catalyst::Controller::REST::DBIC::Item';
+
+__PACKAGE__->config(
+
+);
+
+=head1 NAME
+
+[% CLASS %] - REST Controller for [% schema_class %]
+
+=head1 DESCRIPTION
+
+REST Methods to access the DBIC Schema Class [% schema_class %]
+
+=head1 AUTHOR
+
+[% author %]
+
+=head1 SEE ALSO
+
+L<[% app %]>
+
+L<[% app %]::Model::[% schema_claass %]>
+
+L<Catalyst::Action::REST>
+
+=head1 LICENSE
+
+[% license %]
+
+=cut
+
+1;
+

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/.00-load.t.swp
===================================================================
(Binary files differ)


Property changes on: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/.00-load.t.swp
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/00-load.t
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/00-load.t	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/00-load.t	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,40 @@
+use Test::More qw/no_plan/;
+
+use YAML::Syck;
+use File::Spec;
+use FindBin '$Bin';
+use lib File::Spec->catdir($Bin, 'lib');
+
+BEGIN {
+	use_ok( 'Catalyst::Controller::REST::DBIC::Item' );
+	use_ok( 'TestApp::Schema' );
+}
+
+my $schema = TestApp::Schema->init_schema;
+
+use Test::WWW::Mechanize::Catalyst 'TestApp';
+
+my $mech = Test::WWW::Mechanize::Catalyst->new;
+
+# Create a book called 'name'
+my $res = $mech->get('/book/test_book', 'Content-type' => 'text/x-yaml' );
+diag( $res->content );
+is($res->code, '404', "Book doesn't exist");
+my $test_data = YAML::Syck::Dump({ name => "test_book", isbn => "1234" });
+diag( $test_data );
+
+my $res = $mech->post( '/book/test_book', 
+    'Content-type' => 'text/x-yaml',
+    Content => $test_data 
+);
+
+is($res->code, '405', "Book has no post method");
+like($res->content, qr/Method POST not implemented/, 'No post on book');
+
+my $res = $mech->put( '/book/test_book', 
+    'Content-type' => 'text/x-yaml',
+    Content => $test_data 
+);
+
+is($res->code, '405', "Book has no put method");
+like($res->content, qr/Method PUT not implemented/, 'No post on book');

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/boilerplate.t
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/boilerplate.t	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/boilerplate.t	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,55 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+sub not_in_file_ok {
+    my ($filename, %regex) = @_;
+    open( my $fh, '<', $filename )
+        or die "couldn't open $filename for reading: $!";
+
+    my %violated;
+
+    while (my $line = <$fh>) {
+        while (my ($desc, $regex) = each %regex) {
+            if ($line =~ $regex) {
+                push @{$violated{$desc}||=[]}, $.;
+            }
+        }
+    }
+
+    if (%violated) {
+        fail("$filename contains boilerplate text");
+        diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
+    } else {
+        pass("$filename contains no boilerplate text");
+    }
+}
+
+sub module_boilerplate_ok {
+    my ($module) = @_;
+    not_in_file_ok($module =>
+        'the great new $MODULENAME'   => qr/ - The great new /,
+        'boilerplate description'     => qr/Quick summary of what the module/,
+        'stub function definition'    => qr/function[12]/,
+    );
+}
+
+TODO: {
+  local $TODO = "Need to replace the boilerplate text";
+
+  not_in_file_ok(README =>
+    "The README is used..."       => qr/The README is used/,
+    "'version information here'"  => qr/to provide version information/,
+  );
+
+  not_in_file_ok(Changes =>
+    "placeholder date/time"       => qr(Date/time)
+  );
+
+  module_boilerplate_ok('lib/Catalyst/Controller/REST/DBIC/Item.pm');
+
+
+}
+

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Controller/Book.pm
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Controller/Book.pm	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Controller/Book.pm	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,13 @@
+package  # Hide from PAUSE
+    TestApp::Controller::Book;
+
+use base qw(Catalyst::Controller::REST::DBIC::Item);
+
+__PACKAGE__->config({
+    class    => 'Schema::Book',
+    item_key => 'name'
+});
+
+sub rest_base : Chained('.') PathPart('') CaptureArgs(0) { }
+
+1;

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Controller/Root.pm
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Controller/Root.pm	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Controller/Root.pm	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,22 @@
+package  # Hide from PAUSE
+    TestApp::Controller::Root;
+
+use base qw(Catalyst::Controller);
+
+__PACKAGE__->config->{namespace} = '';
+
+sub rest_base : Chained('.') PathPart('') CaptureArgs(0) { }
+sub default : Private {
+    my ( $self, $c ) = @_;
+
+    $c->res->status(404);
+    $c->res->body(qq{Nothing Here});
+}
+
+sub base : Chained('/') PathPart('') CaptureArgs(0) { }
+
+sub book      : Chained('base') CaptureArgs(0) { }
+sub author    : Chained('base') CaptureArgs(0) { }
+sub publisher : Chained('base') CaptureArgs(0) { }
+
+1;

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Model/Schema.pm
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Model/Schema.pm	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Model/Schema.pm	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,12 @@
+package # Hide from PAUSE
+    TestApp::Model::Schema;
+
+use strict;
+use base 'Catalyst::Model::DBIC::Schema';
+
+__PACKAGE__->config(
+    schema_class => 'TestApp::Schema',
+    
+);
+
+1;

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Schema/Book.pm
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Schema/Book.pm	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Schema/Book.pm	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,25 @@
+package TestApp::Schema::Book;
+
+use base 'DBIx::Class';
+
+my $CLASS = __PACKAGE__;
+
+use overload '""' => sub { $_[0]->name() }, fallback => 1;
+
+$CLASS->load_components( qw|Core| );
+$CLASS->table('book');
+
+$CLASS->add_columns(
+    'pk1',
+    { data_type => 'integer', size => 16, is_nullable => 0,
+        is_auto_increment => 1 },
+    'name',
+    { data_type => 'varchar', size => 128, is_nullable => 0 },
+    'isbn',
+    { data_type => 'varchar', size => 128, is_nullable => 0 },
+);
+
+$CLASS->set_primary_key(qw/pk1/);
+
+1;
+

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Schema.pm
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Schema.pm	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp/Schema.pm	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,30 @@
+package # hide from PAUSE
+    TestApp::Schema;
+
+use warnings;
+use strict;
+
+use base qw/DBIx::Class::Schema/;
+
+use FindBin qw($Bin);
+
+__PACKAGE__->load_classes;
+
+sub init_schema {
+    my ( $self ) = @_;
+
+    my $db_dir  = File::Spec->catdir($Bin, "var");
+    my $db_file = File::Spec->catfile($db_dir, "Test.db");
+
+    unlink($db_file) if -e $db_file;
+    unlink($db_file . "-journal") if -e $db_file . "-journal";
+    mkdir($db_dir) unless -d $db_dir;
+
+    my $dsn = "dbi:SQLite:dbname=${db_file}";
+    my $schema = TestApp::Schema->connect($dsn);
+    $schema->deploy();
+    return $schema;
+}
+
+1;
+

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp.pm
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp.pm	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/lib/TestApp.pm	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,0 +1,26 @@
+package # Hide from PAUSE
+    TestApp;
+
+use Catalyst qw(
+    I18N
+);
+use FindBin;
+
+TestApp->config(
+    root => "$FindBin::Bin/root",
+    'Model::Schema' => {
+        connect_info => [
+            "dbi:SQLite:dbname=" . TestApp->path_to('../../var/Test.db')
+        ]
+    },
+    default_view => 'TT',
+    'View::Email::AppConfig' => {
+        sender => {
+            method => 'Test',
+        },
+    },
+);
+
+TestApp->setup;
+
+1;

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/pod-coverage.t
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/pod-coverage.t	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/pod-coverage.t	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,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: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/pod.t
===================================================================
--- Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/pod.t	                        (rev 0)
+++ Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/pod.t	2008-04-30 15:27:03 UTC (rev 7660)
@@ -0,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();

Added: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/var/Test.db
===================================================================
(Binary files differ)


Property changes on: Catalyst-Controller-REST-DBIC-Item/trunk/0.01/t/var/Test.db
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream




More information about the Catalyst-commits mailing list