[Bast-commits] r3990 - in DBIx-Class-Fixtures/1.000/trunk: . lib
lib/DBIx lib/DBIx/Class t t/var
captainL at dev.catalyst.perl.org
captainL at dev.catalyst.perl.org
Wed Jan 30 13:28:50 GMT 2008
Author: captainL
Date: 2008-01-30 13:28:49 +0000 (Wed, 30 Jan 2008)
New Revision: 3990
Added:
DBIx-Class-Fixtures/1.000/trunk/Changes
DBIx-Class-Fixtures/1.000/trunk/MANIFEST
DBIx-Class-Fixtures/1.000/trunk/Makefile.PL
DBIx-Class-Fixtures/1.000/trunk/README
DBIx-Class-Fixtures/1.000/trunk/lib/
DBIx-Class-Fixtures/1.000/trunk/lib/DBIx/
DBIx-Class-Fixtures/1.000/trunk/lib/DBIx/Class/
DBIx-Class-Fixtures/1.000/trunk/lib/DBIx/Class/Fixtures.pm
DBIx-Class-Fixtures/1.000/trunk/t/
DBIx-Class-Fixtures/1.000/trunk/t/00-load.t
DBIx-Class-Fixtures/1.000/trunk/t/01-new.t
DBIx-Class-Fixtures/1.000/trunk/t/var/
DBIx-Class-Fixtures/1.000/trunk/t/var/configs/
Log:
skeleton checkin, largely stolen from DBIx::Class::Partitioned
Added: DBIx-Class-Fixtures/1.000/trunk/Changes
===================================================================
--- DBIx-Class-Fixtures/1.000/trunk/Changes (rev 0)
+++ DBIx-Class-Fixtures/1.000/trunk/Changes 2008-01-30 13:28:49 UTC (rev 3990)
@@ -0,0 +1,3 @@
+Revision history for DBIx-Class-Fixtures
+
+
Added: DBIx-Class-Fixtures/1.000/trunk/MANIFEST
===================================================================
--- DBIx-Class-Fixtures/1.000/trunk/MANIFEST (rev 0)
+++ DBIx-Class-Fixtures/1.000/trunk/MANIFEST 2008-01-30 13:28:49 UTC (rev 3990)
@@ -0,0 +1,6 @@
+Changes
+MANIFEST
+Makefile.PL
+README
+lib/DBIx/Class/Fixtures.pm
+t/00-load.t
Added: DBIx-Class-Fixtures/1.000/trunk/Makefile.PL
===================================================================
--- DBIx-Class-Fixtures/1.000/trunk/Makefile.PL (rev 0)
+++ DBIx-Class-Fixtures/1.000/trunk/Makefile.PL 2008-01-30 13:28:49 UTC (rev 3990)
@@ -0,0 +1,15 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'DBIx::Class::Fixtures',
+ AUTHOR => 'Luke Saunders <luke at shadowcatsystems.co.uk>',
+ VERSION_FROM => 'lib/DBIx/Class/Fixtures.pm',
+ PL_FILES => {},
+ PREREQ_PM => {
+ 'Test::More' => 0,
+ },
+ dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+ clean => { FILES => 'DBIx-Class-Fixtures-*' },
+);
Added: DBIx-Class-Fixtures/1.000/trunk/README
===================================================================
--- DBIx-Class-Fixtures/1.000/trunk/README (rev 0)
+++ DBIx-Class-Fixtures/1.000/trunk/README 2008-01-30 13:28:49 UTC (rev 3990)
@@ -0,0 +1,20 @@
+DBIx-Class-Fixtures
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+COPYRIGHT AND LICENCE
+
+Development sponsored by takkle.com
+
+Copyright (C) 2008 Luke Saunders <luke at shadowcatsystems.com>, some rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
Added: DBIx-Class-Fixtures/1.000/trunk/lib/DBIx/Class/Fixtures.pm
===================================================================
--- DBIx-Class-Fixtures/1.000/trunk/lib/DBIx/Class/Fixtures.pm (rev 0)
+++ DBIx-Class-Fixtures/1.000/trunk/lib/DBIx/Class/Fixtures.pm 2008-01-30 13:28:49 UTC (rev 3990)
@@ -0,0 +1,82 @@
+package DBIx::Class::Fixtures;
+
+use strict;
+use warnings;
+
+use DBIx::Class::Exception;
+use Class::Accessor;
+use Path::Class qw(dir file);
+use FindBin;
+use JSON::Syck qw(LoadFile);
+use Data::Dumper;
+
+use base qw(Class::Accessor);
+
+__PACKAGE__->mk_accessors(qw(config_dir));
+
+=head1 VERSION
+
+Version 1.000
+
+=cut
+
+our $VERSION = '1.000';
+
+=head1 NAME
+
+=head1 SYNOPSIS
+
+ use DBIx::Class::Fixtures;
+
+ ...
+
+ my $fixtures = DBIx::Class::Fixtures->new({ config_dir => '/home/me/app/fixture_configs' });
+
+ $fixtures->dump({
+ config => 'set_config.json',
+ schema => $source_dbic_schema,
+ directory => '/home/me/app/fixtures'
+ });
+
+ $fixtures->populate({
+ directory => '/home/me/app/fixtures',
+ ddl => '/home/me/app/sql/ddl.sql',
+ connection_details => ['dbi:mysql:dbname=app_dev', 'me', 'password']
+ });
+
+=head1 DESCRIPTION
+
+=head1 AUTHOR
+
+=head1 CONTRIBUTORS
+
+=cut
+
+
+sub new {
+ my $class = shift;
+
+ my ($params) = @_;
+ unless (ref $params eq 'HASH') {
+ return DBIx::Class::Exception->throw('first arg to DBIx::Class::Fixtures->new() must be hash ref');
+ }
+
+ unless ($params->{config_dir}) {
+ return DBIx::Class::Exception->throw('config_dir param not specified');
+ }
+
+ my $config_dir = dir($params->{config_dir});
+ unless (-e $params->{config_dir}) {
+ return DBIx::Class::Exception->throw('config_dir directory doesn\'t exist');
+ }
+
+ my $self = {
+ config_dir => $config_dir
+ };
+
+ bless $self, $class;
+
+ return $self;
+}
+
+1;
Added: DBIx-Class-Fixtures/1.000/trunk/t/00-load.t
===================================================================
--- DBIx-Class-Fixtures/1.000/trunk/t/00-load.t (rev 0)
+++ DBIx-Class-Fixtures/1.000/trunk/t/00-load.t 2008-01-30 13:28:49 UTC (rev 3990)
@@ -0,0 +1,9 @@
+#!perl -T
+
+use Test::More tests => 1;
+
+BEGIN {
+ use_ok( 'DBIx::Class::Fixtures' );
+}
+
+diag( "Testing DBIx::Class::Fixtures $DBIx::Class::Fixtures::VERSION, Perl $], $^X" );
Added: DBIx-Class-Fixtures/1.000/trunk/t/01-new.t
===================================================================
--- DBIx-Class-Fixtures/1.000/trunk/t/01-new.t (rev 0)
+++ DBIx-Class-Fixtures/1.000/trunk/t/01-new.t 2008-01-30 13:28:49 UTC (rev 3990)
@@ -0,0 +1,19 @@
+#!perl
+
+use DBIx::Class::Fixtures;
+use Test::More tests => 3;
+
+my $config_dir = 't/var/configs';
+my $imaginary_config_dir = 't/var/not_there';
+
+eval {
+ DBIx::Class::Fixtures->new({ });
+};
+ok($@, 'new errors without config dir');
+
+eval {
+ DBIx::Class::Fixtures->new({ config_dir => $imaginary_config_dir });
+};
+ok($@, 'new errors with non-existent config dir');
+
+ok(my $fixtures = DBIx::Class::Fixtures->new({ config_dir => $config_dir }), 'object created with correct config dir');
More information about the Bast-commits
mailing list