Catalyst-Model-CDBI-0.12/0000755000076500000240000000000011334145151013336 5ustar t0mstaffCatalyst-Model-CDBI-0.12/Changes0000644000076500000240000000211711334145136014635 0ustar t0mstaffRevision history for Perl extension Catalyst::Model::CDBI. 0.12 Tue Jan 09 02:36:00 - Work around MRO problems in CDBI by massaging CDBI::__::Base's ISA - Switch from NEXT to MRO::Compat - Switch from Catalyst::Base to Catalyst::Component - Fix RT#18197 - Add deprecation notice. 0.11 Wed Nov 23 09:46:00 2005 - Throw an exception during startup if there is an error loading tables. 0.10 Thu Oct 27 17:40:00 2005 - Pass all args to constructor ( Fix global config ) 0.09 Sat Apr 30 23:13:00 2005 - Fixed helper templates 0.08 Sat Apr 30 23:13:00 2005 - added dependency for Class::DBI::Loader 0.20 0.07 Sat Apr 23 16:46:00 2005 - fixed helper (Robert Boone) 0.06 Fri Apr 15 15:52:00 2005 - Added POD tests. - Some doc fixes. 0.05 Mon Mar 14 22:00:00 2005 - fixed helper 0.04 Thu Mar 10 10:00:00 2005 - support for test directories 0.03 Fri Mar 04 20:00:00 2005 - new helper api 0.02 Tue Mar 01 10:00:00 2005 - added helper 0.01 Fri Jan 28 22:00:00 2005 - first release Catalyst-Model-CDBI-0.12/lib/0000755000076500000240000000000011334145151014104 5ustar t0mstaffCatalyst-Model-CDBI-0.12/lib/Catalyst/0000755000076500000240000000000011334145151015670 5ustar t0mstaffCatalyst-Model-CDBI-0.12/lib/Catalyst/Helper/0000755000076500000240000000000011334145151017107 5ustar t0mstaffCatalyst-Model-CDBI-0.12/lib/Catalyst/Helper/Model/0000755000076500000240000000000011334145151020147 5ustar t0mstaffCatalyst-Model-CDBI-0.12/lib/Catalyst/Helper/Model/CDBI.pm0000644000076500000240000000633311334145122021211 0ustar t0mstaffpackage Catalyst::Helper::Model::CDBI; use strict; use Class::DBI::Loader; use Class::DBI; use File::Spec; =head1 NAME Catalyst::Helper::Model::CDBI - Helper for CDBI Models =head1 SYNOPSIS script/create.pl model CDBI CDBI dsn user password =head1 DESCRIPTION Helper for CDBI Model. =head2 METHODS =over 4 =item mk_compclass Reads the database and makes a main model class as well as placeholders for each table. =item mk_comptest Makes tests for the CDBI Model. =back =cut sub mk_compclass { my ( $self, $helper, $dsn, $user, $pass ) = @_; $helper->{dsn} = $dsn || ''; $helper->{user} = $user || ''; $helper->{pass} = $pass || ''; $helper->{rel} = $dsn =~ /sqlite|pg|mysql/i ? 1 : 0; my $file = $helper->{file}; $helper->{classes} = []; $helper->render_file( 'cdbiclass', $file ); #push( @{ $helper->{classes} }, $helper->{class} ); return 1 unless $dsn; my $loader = Class::DBI::Loader->new( dsn => $dsn, user => $user, password => $pass, namespace => $helper->{class} ); my $path = $file; $path =~ s/\.pm$//; $helper->mk_dir($path); for my $c ( $loader->classes ) { $helper->{tableclass} = $c; $helper->{tableclass} =~ /\W*(\w+)$/; my $f = $1; my $p = File::Spec->catfile( $path, "$f.pm" ); $helper->render_file( 'tableclass', $p ); push( @{ $helper->{classes} }, $c ); } return 1; } sub mk_comptest { my ( $self, $helper ) = @_; my $test = $helper->{test}; my $name = $helper->{name}; for my $c ( @{ $helper->{classes} } ) { $helper->{tableclass} = $c; $helper->{tableclass} =~ /\:\:(\w+)\:\:(\w+)$/; my $prefix; unless ( $1 eq 'M' ) { $prefix = "$name\::$2" } else { $prefix = $2 } $prefix =~ s/::/-/g; my $test = $helper->next_test($prefix); $helper->render_file( 'test', $test ); } } =head1 SEE ALSO L, L, L, L, L =head1 AUTHOR Sebastian Riedel, C =head1 LICENSE This library is free software . You can redistribute it and/or modify it under the same terms as perl itself. =cut 1; __DATA__ __cdbiclass__ package [% class %]; use strict; use base 'Catalyst::Model::CDBI'; __PACKAGE__->config( dsn => '[% dsn %]', user => '[% user %]', password => '[% pass %]', options => {}, relationships => [% rel %] ); =head1 NAME [% class %] - CDBI Model Component =head1 SYNOPSIS See L<[% app %]> =head1 DESCRIPTION CDBI Model Component. =head1 AUTHOR [% author %] =head1 LICENSE This library is free software . You can redistribute it and/or modify it under the same terms as perl itself. =cut 1; __tableclass__ package [% tableclass %]; use strict; =head1 NAME [% tableclass %] - CDBI Table Class =head1 SYNOPSIS See L<[% app %]> =head1 DESCRIPTION CDBI Table Class. =head1 AUTHOR [% author %] =head1 LICENSE This library is free software . You can redistribute it and/or modify it under the same terms as perl itself. =cut 1; __test__ use Test::More tests => 2; use_ok( Catalyst::Test, '[% app %]' ); use_ok('[% tableclass %]'); Catalyst-Model-CDBI-0.12/lib/Catalyst/Model/0000755000076500000240000000000011334145151016730 5ustar t0mstaffCatalyst-Model-CDBI-0.12/lib/Catalyst/Model/CDBI.pm0000644000076500000240000000547411334144646020011 0ustar t0mstaffpackage Catalyst::Model::CDBI; # work around CDBI being incompatible with C3 mro, due to both Ima::DBI and Class::DBI::__::Base # inheriting from Class::Data::Inheritable in an inconsistent order. BEGIN { require Class::DBI; @Class::DBI::__::Base::ISA = grep { $_ ne 'Class::Data::Inheritable' } @Class::DBI::__::Base::ISA; } use strict; use base qw/Catalyst::Component Class::DBI/; use MRO::Compat; use Class::DBI::Loader; our $VERSION = '0.12'; __PACKAGE__->mk_accessors('loader'); =head1 NAME Catalyst::Model::CDBI - [DEPRECATED] CDBI Model Class =head1 SYNOPSIS # use the helper create model CDBI CDBI dsn user password # lib/MyApp/Model/CDBI.pm package MyApp::Model::CDBI; use base 'Catalyst::Model::CDBI'; __PACKAGE__->config( dsn => 'dbi:Pg:dbname=myapp', password => '', user => 'postgres', options => { AutoCommit => 1 }, relationships => 1 ); 1; # As object method $c->comp('MyApp::Model::CDBI::Table')->search(...); # As class method MyApp::Model::CDBI::Table->search(...); =head1 DESCRIPTION This is the C model class. It's built on top of C. C is generally not used for new applications, with C being preferred instead. As such this model is deprecated and (mostly) unmaintained. It is preserved here for older applications which still need it for backwards compatibility. =head2 new Initializes Class::DBI::Loader and loads classes using the class config. Also attempts to borg all the classes. =cut sub new { my $class = shift; my $self = $class->next::method( @_ ); my $c = shift; $self->{namespace} ||= ref $self; $self->{additional_base_classes} ||= (); push @{ $self->{additional_base_classes} }, ref $self; eval { $self->loader( Class::DBI::Loader->new(%$self) ) }; if ($@) { Catalyst::Exception->throw( message => $@ ); } else { $c->log->debug( 'Loaded tables "' . join( ' ', $self->loader->tables ) . '"' ) if $c->debug; } for my $class ( $self->loader->classes ) { $class->autoupdate(1); $c->components->{$class} ||= bless {%$self}, $class; no strict 'refs'; *{"$class\::new"} = sub { bless {%$self}, $class }; } return $self; } =head1 SEE ALSO L, L L =head1 AUTHOR Sebastian Riedel, C =head1 CONTRIBUTORS mst: Matt S Trout C Arathorn: Matthew Hodgson C =head1 COPYRIGHT Copyright (c) 2005 - 2010 the Catalyst::Model::CDBI L and L as listed above. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; Catalyst-Model-CDBI-0.12/Makefile.PL0000644000076500000240000000053711334144732015321 0ustar t0mstaffuse ExtUtils::MakeMaker; WriteMakefile( NAME => 'Catalyst::Model::CDBI', AUTHOR => 'Sebastian Riedel (sri@oook.de)', PREREQ_PM => { Catalyst => '4.00', MRO::Compat => 0, Class::DBI => 0, Class::DBI::Loader => 0.20 }, VERSION_FROM => 'lib/Catalyst/Model/CDBI.pm' ); Catalyst-Model-CDBI-0.12/MANIFEST0000644000076500000240000000024511334144777014505 0ustar t0mstaffChanges lib/Catalyst/Helper/Model/CDBI.pm lib/Catalyst/Model/CDBI.pm Makefile.PL MANIFEST This list of files META.yml README t/01use.t t/02pod.t t/03podcoverage.t Catalyst-Model-CDBI-0.12/META.yml0000644000076500000240000000115311334145151014607 0ustar t0mstaff--- #YAML:1.0 name: Catalyst-Model-CDBI version: 0.12 abstract: ~ author: - Sebastian Riedel (sri@oook.de) license: unknown distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: Catalyst: 4.00 Class::DBI: 0 Class::DBI::Loader: 0.2 MRO::Compat: 0 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.54 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Catalyst-Model-CDBI-0.12/README0000644000076500000240000000167511234171165014232 0ustar t0mstaffNAME Catalyst::Model::CDBI - CDBI Model Class SYNOPSIS # use the helper create model CDBI CDBI dsn user password # lib/MyApp/Model/CDBI.pm package MyApp::Model::CDBI; use base 'Catalyst::Model::CDBI'; __PACKAGE__->config( dsn => 'dbi:Pg:dbname=myapp', password => '', user => 'postgres', options => { AutoCommit => 1 }, relationships => 1 ); 1; # As object method $c->comp('MyApp::Model::CDBI::Table')->search(...); # As class method MyApp::Model::CDBI::Table->search(...); DESCRIPTION This is the "Class::DBI", "Class::DBI::Loader" model class. SEE ALSO Catalyst, Class::DBI AUTHOR Sebastian Riedel, "sri@cpan.org" COPYRIGHT This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. Catalyst-Model-CDBI-0.12/t/0000755000076500000240000000000011334145151013601 5ustar t0mstaffCatalyst-Model-CDBI-0.12/t/01use.t0000644000076500000240000000034411322121147014720 0ustar t0mstaffuse strict; use Test::More tests => 3; BEGIN { use_ok('Catalyst::Model::CDBI') } BEGIN { use_ok('Catalyst::Helper::Model::CDBI') } use MRO::Compat; ok(eval { mro::get_linear_isa('Catalyst::Model::CDBI'); 1 }, 'Linearise ok'); Catalyst-Model-CDBI-0.12/t/02pod.t0000644000076500000240000000027611234171165014722 0ustar t0mstaffuse Test::More; eval "use Test::Pod 1.14"; plan skip_all => 'Test::Pod 1.14 required' if $@; plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; all_pod_files_ok(); Catalyst-Model-CDBI-0.12/t/03podcoverage.t0000644000076500000240000000032511234171165016432 0ustar t0mstaffuse Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; all_pod_coverage_ok();