[Bast-commits] r6995 - in DBIx-Class-Schema-PopulateMore/truck: . lib/DBIx/Class/Schema lib/DBIx/Class/Schema/PopulateMore lib/DBIx/Class/Schema/PopulateMore/Inflator

jnapiorkowski at dev.catalyst.perl.org jnapiorkowski at dev.catalyst.perl.org
Mon Jul 6 14:02:42 GMT 2009


Author: jnapiorkowski
Date: 2009-07-06 14:02:41 +0000 (Mon, 06 Jul 2009)
New Revision: 6995

Modified:
   DBIx-Class-Schema-PopulateMore/truck/Changes
   DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore.pm
   DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Command.pm
   DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator.pm
   DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Date.pm
   DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Env.pm
   DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Find.pm
   DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Index.pm
   DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Visitor.pm
Log:
updated docs, find bug that caused us to have trouble finding the right Index, now uses DBIC->throw_exception instead of confess, minor change to the  Data::Visitor subclass to properly reflect that module being on Any::Moose now

Modified: DBIx-Class-Schema-PopulateMore/truck/Changes
===================================================================
--- DBIx-Class-Schema-PopulateMore/truck/Changes	2009-07-05 23:12:57 UTC (rev 6994)
+++ DBIx-Class-Schema-PopulateMore/truck/Changes	2009-07-06 14:02:41 UTC (rev 6995)
@@ -1,5 +1,11 @@
 Revision history for Perl extension DBIx-Class-Schema-PopulateMore.
 
+0.13 Monday, July 6, 2009
+    - Fix an error with the way we parse command inflators so that if a source
+      string contains '::' it won't give us the wrong lookup index
+    - Changed from using 'confess' to using the DBIC throw exception method
+    - More minor documentation updates.
+
 0.12 Tuesday, June 30, 2009
     - More tweaks to try and fix my broken local Module::Install
 

Modified: DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Command.pm
===================================================================
--- DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Command.pm	2009-07-05 23:12:57 UTC (rev 6994)
+++ DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Command.pm	2009-07-06 14:02:41 UTC (rev 6995)
@@ -31,10 +31,21 @@
 has 'schema' => (
 	is=>'ro',
 	required=>1,
-	isa=>'DBIx::Class::Schema',
+	isa=>'Object',
 );
 
+=head2 exception_cb
 
+contains a callback to the exception method supplied by DBIC
+
+=cut
+
+has 'exception_cb' => (
+	is=>'ro',
+	required=>1,
+	isa=>'CodeRef',
+);
+
 =head2 definitions
 
 This is an arrayref of information used to populate tables in the database
@@ -255,8 +266,8 @@
 
 sub dispatch_inflator
 {
-	my $self = shift @_;
-	my ($name, $command) = split(':', shift);
+	my ($self, $arg) = @_;
+	my ($name, $command) =  ($arg =~m/^(\w+):(\w.+)$/); 
 	
 	if( my $inflator = $self->get_inflator($name) )
 	{
@@ -265,7 +276,7 @@
 	else
 	{
 		my $available = join(', ', $self->inflator_list);
-		confess "Can't Handle $name, available are: $available";
+		$self->exception_cb->("Can't Handle $name, available are: $available");
 	}
 }
 

Modified: DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Date.pm
===================================================================
--- DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Date.pm	2009-07-05 23:12:57 UTC (rev 6994)
+++ DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Date.pm	2009-07-06 14:02:41 UTC (rev 6995)
@@ -40,7 +40,7 @@
 	}
 	else
 	{
-		confess "Couldn't deal with $string as a date";
+		$command->exception_cb->("Couldn't deal with $string as a date");
 	}
 
 }

Modified: DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Env.pm
===================================================================
--- DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Env.pm	2009-07-05 23:12:57 UTC (rev 6994)
+++ DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Env.pm	2009-07-06 14:02:41 UTC (rev 6995)
@@ -38,6 +38,10 @@
 	{
 		return $ENV{uc $string};
 	}
+	else
+	{
+		$command->exception_cb->("No match for $string found in %ENV");
+	}
 	
 	return;
 }

Modified: DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Find.pm
===================================================================
--- DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Find.pm	2009-07-05 23:12:57 UTC (rev 6994)
+++ DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Find.pm	2009-07-06 14:02:41 UTC (rev 6995)
@@ -46,10 +46,10 @@
 		if(my $result = $resultset->find($id)) {
 			return $result;
 		} else {
-			confess "Can't find result for '$id' in '$source'";
+			$command->exception_cb->("Can't find result for '$id' in '$source'");
 		}
 	} else {
-		confess "Can't find resultset for $source in $string";
+		$command->exception_cb->("Can't find resultset for $source in $string");
 	}
 	return;
 }

Modified: DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Index.pm
===================================================================
--- DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Index.pm	2009-07-05 23:12:57 UTC (rev 6994)
+++ DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator/Index.pm	2009-07-06 14:02:41 UTC (rev 6995)
@@ -31,7 +31,7 @@
 	my ($self, $command, $string) = @_;
 
 	return $command->get_rs_index($string)
-	 || confess "Bad Index in Fixture: $string";
+	 || $command->exception_cb->("Bad Index in Fixture: $string");
 }
 
 

Modified: DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator.pm
===================================================================
--- DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator.pm	2009-07-05 23:12:57 UTC (rev 6994)
+++ DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Inflator.pm	2009-07-06 14:02:41 UTC (rev 6995)
@@ -49,7 +49,7 @@
 
 sub inflate
 { 
-	confess "You forgot to implement ->inflate";
+	die "You forgot to implement ->inflate";
 }
 
 

Modified: DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Visitor.pm
===================================================================
--- DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Visitor.pm	2009-07-05 23:12:57 UTC (rev 6994)
+++ DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore/Visitor.pm	2009-07-06 14:02:41 UTC (rev 6995)
@@ -1,7 +1,7 @@
 package DBIx::Class::Schema::PopulateMore::Visitor;
 
 use Moose;
-extends 'Data::Visitor', 'Moose::Object';
+extends 'Data::Visitor';
 
 =head1 NAME
 

Modified: DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore.pm
===================================================================
--- DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore.pm	2009-07-05 23:12:57 UTC (rev 6994)
+++ DBIx-Class-Schema-PopulateMore/truck/lib/DBIx/Class/Schema/PopulateMore.pm	2009-07-06 14:02:41 UTC (rev 6995)
@@ -11,11 +11,11 @@
 
 =head1 VERSION
 
-Version 0.12
+Version 0.13
 
 =cut
 
-our $VERSION = '0.12';
+our $VERSION = '0.13';
 
 =head1 SYNOPSIS
 
@@ -97,7 +97,7 @@
 =item Env
 
 Get's it's value from %ENV.  Typically this will be setup in your shell or at
-application runtime.
+application runtime.  This is a string in the form of "!Env:MY_ENV_VAR"
 
 =item Date
 
@@ -113,8 +113,11 @@
 Used for when you want the value of something that you expect already exists
 in the database (but for which you didn't just populatemore for, use 'Index'
 for that case.) Use cases for this include lookup style tables, like 'Status'
-or 'Gender', 'State', etc. which you may already have installed.
+or 'Gender', 'State', etc. which you may already have installed. This is a
+string in the form of '!Find:Source.[key1=val1,key2=val2,...'.
 
+If your find doesn't return a single result, expect an error.
+
 It's trivial to write more; please feel free to post me your contributions.
 
 =back
@@ -161,6 +164,9 @@
 		$command = DBIx::Class::Schema::PopulateMore::Command->new(
 			definitions=>$arg,
 			schema=>$self,
+			exception_cb=>sub {
+				$self->throw_exception(@_);
+			},
 		);
 	}; if ($@) {
 		$self->throw_exception("Can't create Command: $@");




More information about the Bast-commits mailing list