From: John Napiorkowski Date: Fri, 9 Mar 2012 05:58:18 +0000 (-0500) Subject: more correctly restore path with external file X-Git-Tag: 1.001015~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a3ebae957ae515eea596ebebc8a16f2b0a339938;p=dbsrgits%2FDBIx-Class-Fixtures.git more correctly restore path with external file --- diff --git a/.gitignore b/.gitignore index 3268211..bff1e61 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .*.sw? +\.DS_Store diff --git a/Changes b/Changes index 9a34a67..0084543 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for DBIx-Class-Fixtures +1.001015 +- ::External::File makes the path if its missing + 1.001014 - Allow you to perform value substitutions inside config-sets - Added a framework to allow you to backup / restore data external to the diff --git a/Makefile.PL b/Makefile.PL index 42bff91..62b15e0 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -18,6 +18,7 @@ requires 'Hash::Merge' => 0.10; requires 'Scalar::Util'; requires 'MIME::Base64'; requires 'File::Spec::Functions'; +requires 'File::Path'; requires 'DateTime::Format::SQLite' => 0.10; requires 'DateTime::Format::MySQL' => 0; diff --git a/lib/DBIx/Class/Fixtures.pm b/lib/DBIx/Class/Fixtures.pm index aef6647..a8da170 100644 --- a/lib/DBIx/Class/Fixtures.pm +++ b/lib/DBIx/Class/Fixtures.pm @@ -28,7 +28,7 @@ __PACKAGE__->mk_group_accessors( 'simple' => qw/config_dir =head1 VERSION -Version 1.001013 +Version 1.001014 =cut diff --git a/lib/DBIx/Class/Fixtures/External/File.pm b/lib/DBIx/Class/Fixtures/External/File.pm index 97fd5fb..4277e7b 100644 --- a/lib/DBIx/Class/Fixtures/External/File.pm +++ b/lib/DBIx/Class/Fixtures/External/File.pm @@ -3,7 +3,8 @@ package DBIx::Class::Fixtures::External::File; use strict; use warnings; -use File::Spec::Functions 'catfile'; +use File::Spec::Functions 'catfile', 'splitpath'; +use File::Path 'mkpath'; sub _load { my ($class, $path) = @_; @@ -29,7 +30,9 @@ sub backup { sub restore { my ($class, $key, $content, $args) = @_; - my $path = catfile($args->{path}, $key); + my ($vol, $directory, $file) = splitpath catfile($args->{path}, $key); + mkpath($directory) unless -d $directory; + my $path = catfile($vol, $directory, $file); $class->_save($path, $content); }