X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FFixtures.pm;h=24439971d5abbcb7c307029e4d6aad61b9fc28d4;hb=dcdf675f7c1e751f53bce149fe7af49bf079771b;hp=808ffafecb394f6959eec0eb3cd9d4abaa68e9f5;hpb=dcf3c1c8a867ad1e02e49cdfc09ab0b4f7a8f46a;p=dbsrgits%2FDBIx-Class-Fixtures.git diff --git a/lib/DBIx/Class/Fixtures.pm b/lib/DBIx/Class/Fixtures.pm index 808ffaf..2443997 100644 --- a/lib/DBIx/Class/Fixtures.pm +++ b/lib/DBIx/Class/Fixtures.pm @@ -26,7 +26,7 @@ our $namespace_counter = 0; __PACKAGE__->mk_group_accessors( 'simple' => qw/config_dir _inherited_attributes debug schema_class dumped_objects config_attrs/); -our $VERSION = '1.001022'; +our $VERSION = '1.001025'; $VERSION = eval $VERSION; @@ -844,7 +844,7 @@ sub dump_object { # write dir and gen filename - my $source_dir = $params->{set_dir}->subdir(lc $src->from); + my $source_dir = $params->{set_dir}->subdir($self->_name_for_source($src)); $source_dir->mkpath(0, 0777); # strip dir separators from file name @@ -868,7 +868,7 @@ sub dump_object { $ds{external}->{$field} = encode_base64( $class - ->backup($key => $args)); + ->backup($key => $args),''); } } @@ -1045,7 +1045,7 @@ sub _generate_schema { unless( $pre_schema ) { return DBIx::Class::Exception->throw('connection details not valid'); } - my @tables = map { $pre_schema->source($_)->from } $pre_schema->sources; + my @tables = map { $self->_name_for_source($pre_schema->source($_)) } $pre_schema->sources; $self->msg("Tables to drop: [". join(', ', sort @tables) . "]"); my $dbh = $pre_schema->storage->dbh; @@ -1336,7 +1336,7 @@ sub populate { } $self->msg("- creating temp dir"); $tmp_fixture_dir->mkpath(); - for ( map { $schema->source($_)->from } $schema->sources) { + for ( map { $self->_name_for_source($schema->source($_)) } $schema->sources) { my $from_dir = $fixture_dir->subdir($_); next unless -e $from_dir; dircopy($from_dir, $tmp_fixture_dir->subdir($_) ); @@ -1368,7 +1368,7 @@ sub populate { foreach my $source (sort $schema->sources) { $self->msg("- adding " . $source); my $rs = $schema->resultset($source); - my $source_dir = $tmp_fixture_dir->subdir( lc $rs->result_source->from ); + my $source_dir = $tmp_fixture_dir->subdir( $self->_name_for_source($rs->result_source) ); next unless (-e $source_dir); my @rows; while (my $file = $source_dir->next) { @@ -1457,6 +1457,16 @@ sub msg { } } +# Helper method for ensuring that the name used for a given source +# is always the same (This is used to name the fixture directories +# for example) + +sub _name_for_source { + my ($self, $source) = @_; + + return ref $source->name ? $source->source_name : $source->name; +} + =head1 AUTHOR Luke Saunders