[Bast-commits] r4898 - in DBIx-Class-InflateColumn-FS/1.000/trunk:
. lib/DBIx/Class/InflateColumn lib/DBIx/Class/InflateColumn/FS t
semifor at dev.catalyst.perl.org
semifor at dev.catalyst.perl.org
Tue Oct 7 03:01:09 BST 2008
Author: semifor
Date: 2008-10-07 03:01:09 +0100 (Tue, 07 Oct 2008)
New Revision: 4898
Added:
DBIx-Class-InflateColumn-FS/1.000/trunk/MANIFEST.SKIP
DBIx-Class-InflateColumn-FS/1.000/trunk/README
DBIx-Class-InflateColumn-FS/1.000/trunk/t/99-pod_spelling.t
DBIx-Class-InflateColumn-FS/1.000/trunk/t/99-pod_syntax.t
Modified:
DBIx-Class-InflateColumn-FS/1.000/trunk/Changes
DBIx-Class-InflateColumn-FS/1.000/trunk/Makefile.PL
DBIx-Class-InflateColumn-FS/1.000/trunk/lib/DBIx/Class/InflateColumn/FS.pm
DBIx-Class-InflateColumn-FS/1.000/trunk/lib/DBIx/Class/InflateColumn/FS/ResultSet.pm
DBIx-Class-InflateColumn-FS/1.000/trunk/t/00-load.t
DBIx-Class-InflateColumn-FS/1.000/trunk/t/01-fs_columns.t
DBIx-Class-InflateColumn-FS/1.000/trunk/t/99-pod_coverage.t
Log:
Use base class DBIx::Class::UUIDColumns for multiple UUID provider support.
Added POD tests and cleaned up for release.
Modified: DBIx-Class-InflateColumn-FS/1.000/trunk/Changes
===================================================================
--- DBIx-Class-InflateColumn-FS/1.000/trunk/Changes 2008-10-07 02:00:41 UTC (rev 4897)
+++ DBIx-Class-InflateColumn-FS/1.000/trunk/Changes 2008-10-07 02:01:09 UTC (rev 4898)
@@ -1,3 +1,8 @@
+0.00000_04 2008-10-06 16:10:00
+ - used base class DBIx::Class::UUIDColumns for it's multiple UUID
+ provider support
+ - added POD tests
+
0.00000_03 2008-10-04 15:20:00
- store only the path name below fs_column_path
Added: DBIx-Class-InflateColumn-FS/1.000/trunk/MANIFEST.SKIP
===================================================================
--- DBIx-Class-InflateColumn-FS/1.000/trunk/MANIFEST.SKIP (rev 0)
+++ DBIx-Class-InflateColumn-FS/1.000/trunk/MANIFEST.SKIP 2008-10-07 02:01:09 UTC (rev 4898)
@@ -0,0 +1,48 @@
+# Avoid version control files.
+\bRCS\b
+\bCVS\b
+,v$
+\B\.svn\b
+^\.git
+
+# Avoid Makemaker generated and utility files.
+\bMakefile$
+\bblib
+\bMakeMaker-\d
+\bpm_to_blib$
+\bblibdirs$
+^MANIFEST\.SKIP$
+
+# for developers only :)
+^TODO$
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\b_build
+
+# Avoid temp and backup files.
+~$
+\.tmp$
+\.old$
+\.bak$
+\..*?\.sw[po]$
+\#$
+\b\.#
+
+# avoid OS X finder files
+\.DS_Store$
+
+# Don't ship the test db
+^t/var
+
+# Don't ship the last dist we built :)
+\.tar\.gz$
+
+# Skip maint stuff
+^maint/
+
+# Avoid copies to .orig
+\.orig$
+
+# Dont use Module::Build anymore
+^Build.PL$
Modified: DBIx-Class-InflateColumn-FS/1.000/trunk/Makefile.PL
===================================================================
--- DBIx-Class-InflateColumn-FS/1.000/trunk/Makefile.PL 2008-10-07 02:00:41 UTC (rev 4897)
+++ DBIx-Class-InflateColumn-FS/1.000/trunk/Makefile.PL 2008-10-07 02:01:09 UTC (rev 4898)
@@ -9,14 +9,10 @@
all_from 'lib/DBIx/Class/InflateColumn/FS.pm';
requires 'DBIx::Class' => 0.08;
-requires 'File::Path' => 0;
-requires 'File::Copy' => 0;
requires 'Path::Class' => 0;
-requires 'Data::UUID' => 0;
+requires 'DBIx::Class::UUIDColumns' => 0.02005;
test_requires 'DBD::SQLite' => 1.12;
test_requires 'DBICx::TestDatabase' => 0;
-test_requires 'File::Compare' => 0;
-test_requires 'File::Temp' => 0;
WriteAll;
Added: DBIx-Class-InflateColumn-FS/1.000/trunk/README
===================================================================
--- DBIx-Class-InflateColumn-FS/1.000/trunk/README (rev 0)
+++ DBIx-Class-InflateColumn-FS/1.000/trunk/README 2008-10-07 02:01:09 UTC (rev 4898)
@@ -0,0 +1,71 @@
+NAME
+ DBIx::Class::InflateColumn::FS - store BLOBs in the file system
+
+SYNOPSIS
+ __PACKAGE__->load_components('InflateColumn::FS Core');
+ __PACKAGE__->add_columns(
+ id => {
+ data_type => 'INT',
+ is_auto_increment => 1,
+ },
+ file => {
+ data_type => 'TEXT',
+ is_fs_column => 1,
+ fs_column_path => '/var/lib/myapp/myfiles',
+ },
+ );
+ __PACKAGE__->set_primary_key('id');
+
+ # in application code
+ $rs->create({ file => $file_handle });
+
+ $row = $rs->find({ id => $id });
+ my $fh = $row->file->open('r');
+
+DESCRIPTION
+ Provides inflation to a Path::Class::File object allowing file system
+ storage of BLOBS.
+
+ The storage path is specified with "fs_column_path". Each file receives
+ a unique name, so the storage for all FS columns can share the same
+ path.
+
+ Within the path specified by "fs_column_path", files are stored in
+ sub-directories based on the first 2 characters of the unique file
+ names. Up to 256 sub-directories will be created, as needed. Override
+ "_fs_column_dirs" in a derived class to change this behavior.
+
+METHODS
+ register_column
+ _fs_column_storage
+ Provides the file naming algorithm. Override this method to change it.
+
+ _fs_column_dirs
+ Returns the sub-directory components for a given file name. Override it
+ to provide a deeper directory tree or change the algorithm.
+
+ delete
+ Deletes the associated file system storage when a row is deleted.
+
+ update
+ Deletes the associated file system storage when a column is set to null.
+
+ _inflate_fs_column
+ Inflates a file column to a Path::Class::File object.
+
+ _deflate_fs_column
+ Deflates a file column to the arbitrary value, 1. In the database, a
+ file column is just a place holder for inflation/deflation. The actual
+ file lives in the file system.
+
+ table
+ Overridden to provide a hook for specifying the resultset_class. If you
+ provide your own resultset_class, inherit from
+ InflateColumn::FS::ResultSet.
+
+AUTHOR
+ Marc Mims <marc at questright.com>
+
+LICENSE
+ You may distribute this code under the same terms as Perl itself.
+
Modified: DBIx-Class-InflateColumn-FS/1.000/trunk/lib/DBIx/Class/InflateColumn/FS/ResultSet.pm
===================================================================
--- DBIx-Class-InflateColumn-FS/1.000/trunk/lib/DBIx/Class/InflateColumn/FS/ResultSet.pm 2008-10-07 02:00:41 UTC (rev 4897)
+++ DBIx-Class-InflateColumn-FS/1.000/trunk/lib/DBIx/Class/InflateColumn/FS/ResultSet.pm 2008-10-07 02:01:09 UTC (rev 4898)
@@ -5,17 +5,17 @@
DBIx::Class::InflateColumn::FS::ResultSet - FS columns resultset class
-=head1 DESCIPTION
+=head1 DESCRIPTION
Derive from this class if you intend to provide a custom resultset
-class for result sources including DBIx::Class::InflateColumn::FS
+class for result sources including L<DBIx::Class::InflateColumn::FS>
columns.
=head1 METHODS
=head2 delete
-Delete each row in a resultset.
+Delete associated file system storage for each row in a result set.
=cut
Modified: DBIx-Class-InflateColumn-FS/1.000/trunk/lib/DBIx/Class/InflateColumn/FS.pm
===================================================================
--- DBIx-Class-InflateColumn-FS/1.000/trunk/lib/DBIx/Class/InflateColumn/FS.pm 2008-10-07 02:00:41 UTC (rev 4897)
+++ DBIx-Class-InflateColumn-FS/1.000/trunk/lib/DBIx/Class/InflateColumn/FS.pm 2008-10-07 02:01:09 UTC (rev 4898)
@@ -2,18 +2,17 @@
use strict;
use warnings;
-use base 'DBIx::Class';
+use base 'DBIx::Class::UUIDColumns';
use File::Spec;
use File::Path;
use File::Copy;
use Path::Class;
-use Data::UUID;
-our $VERSION = '0.00000_03';
+our $VERSION = '0.00000_04';
=head1 NAME
-DBIx::Class::InflateColumn::FS - file columns stored in the file system
+DBIx::Class::InflateColumn::FS - store BLOBs in the file system
=head1 SYNOPSIS
@@ -39,20 +38,17 @@
=head1 DESCRIPTION
-Provides inflation to a Path::Class::File object allowing storage an
-retreival of files in the file system.
+Provides inflation to a Path::Class::File object allowing file system storage
+of BLOBS.
-The path for storing files is specified for each column. Depending upon
-the file naming algorithm, a separate path may be needed for each table
-using InflateColumn::FS, or even for each individual column.
+The storage path is specified with C<fs_column_path>. Each file receives a
+unique name, so the storage for all FS columns can share the same path.
-By default, InflateColumn::FS creates a file in fs_column_path, in a
-subdirectory based on the row ID (assumed to be an integer), and the
-column, name. As an example, with fs_column_path set to 'var/foo',
-for a column named 'bar', with row ID 2192, will be saved as:
+Within the path specified by C<fs_column_path>, files are stored in
+sub-directories based on the first 2 characters of the unique file names. Up to
+256 sub-directories will be created, as needed. Override C<_fs_column_dirs> in
+a derived class to change this behavior.
- var/foo/92/2192_bar
-
=cut
=head1 METHODS
@@ -82,7 +78,7 @@
=head2 _fs_column_storage
-Provides the file naming alorithm. Override this method to change it.
+Provides the file naming algorithm. Override this method to change it.
=cut
@@ -97,7 +93,7 @@
return Path::Class::File->new($column_info->{fs_column_path}, $filename);
}
else {
- $filename = Data::UUID->new->create_str;
+ $filename = $self->get_uuid;
return Path::Class::File->new(
$column_info->{fs_column_path},
$self->_fs_column_dirs($filename),
@@ -108,7 +104,8 @@
=head2 _fs_column_dirs
-Returns a list of directory components for a given file name
+Returns the sub-directory components for a given file name. Override it to
+provide a deeper directory tree or change the algorithm.
=cut
@@ -139,7 +136,7 @@
=head2 update
-Deletes file system storage when an fs_column is set to null.
+Deletes the associated file system storage when a column is set to null.
=cut
@@ -148,7 +145,8 @@
my %changed = ($self->get_dirty_columns, %{$upd || {}});
- # cache existing fs_colums before update so we can delete storge afterwards if necessary
+ # cache existing fs_colums before update so we can delete storge
+ # afterwards if necessary
my %fs_column =
map { ($_, $self->$_) }
grep { $self->column_info($_)->{is_fs_column} }
@@ -172,7 +170,7 @@
=head2 _inflate_fs_column
-Inflates a file coulmn to a Path::Class::File object.
+Inflates a file column to a Path::Class::File object.
=cut
@@ -186,7 +184,7 @@
=head2 _deflate_fs_column
-Deflates a file column to the abitrary value, 1. In the database, a
+Deflates a file column to the arbitrary value, 1. In the database, a
file column is just a place holder for inflation/deflation. The actual
file lives in the file system.
@@ -226,8 +224,10 @@
my $self = shift;
my $ret = $self->next::method(@_);
- if ( @_ && $self->result_source_instance->resultset_class eq 'DBIx::Class::ResultSet' ) {
- $self->result_source_instance->resultset_class('DBIx::Class::InflateColumn::FS::ResultSet');
+ if ( @_ && $self->result_source_instance->resultset_class
+ eq 'DBIx::Class::ResultSet' ) {
+ $self->result_source_instance
+ ->resultset_class('DBIx::Class::InflateColumn::FS::ResultSet');
}
return $ret;
}
Modified: DBIx-Class-InflateColumn-FS/1.000/trunk/t/00-load.t
===================================================================
--- DBIx-Class-InflateColumn-FS/1.000/trunk/t/00-load.t 2008-10-07 02:00:41 UTC (rev 4897)
+++ DBIx-Class-InflateColumn-FS/1.000/trunk/t/00-load.t 2008-10-07 02:01:09 UTC (rev 4898)
@@ -1,3 +1,4 @@
+#!perl -wT
use warnings;
use strict;
use Test::More tests => 1;
Modified: DBIx-Class-InflateColumn-FS/1.000/trunk/t/01-fs_columns.t
===================================================================
--- DBIx-Class-InflateColumn-FS/1.000/trunk/t/01-fs_columns.t 2008-10-07 02:00:41 UTC (rev 4897)
+++ DBIx-Class-InflateColumn-FS/1.000/trunk/t/01-fs_columns.t 2008-10-07 02:01:09 UTC (rev 4898)
@@ -1,3 +1,4 @@
+#!perl -wT
use warnings;
use strict;
use DBICx::TestDatabase;
Modified: DBIx-Class-InflateColumn-FS/1.000/trunk/t/99-pod_coverage.t
===================================================================
--- DBIx-Class-InflateColumn-FS/1.000/trunk/t/99-pod_coverage.t 2008-10-07 02:00:41 UTC (rev 4897)
+++ DBIx-Class-InflateColumn-FS/1.000/trunk/t/99-pod_coverage.t 2008-10-07 02:01:09 UTC (rev 4898)
@@ -1,7 +1,13 @@
+#!perl -wT
+use warnings;
+use strict;
use Test::More;
+plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
+
eval "use Pod::Coverage 0.19";
plan skip_all => 'Pod::Coverage 0.19 required' if $@;
+
eval "use Test::Pod::Coverage 1.04";
plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
Added: DBIx-Class-InflateColumn-FS/1.000/trunk/t/99-pod_spelling.t
===================================================================
--- DBIx-Class-InflateColumn-FS/1.000/trunk/t/99-pod_spelling.t (rev 0)
+++ DBIx-Class-InflateColumn-FS/1.000/trunk/t/99-pod_spelling.t 2008-10-07 02:01:09 UTC (rev 4898)
@@ -0,0 +1,22 @@
+#!perl -w
+use strict;
+use warnings;
+use Test::More;
+
+plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
+
+eval 'use Test::Spelling 0.11';
+plan skip_all => 'Test::Spelling 0.11 not installed' if $@;
+
+set_spell_cmd('aspell list');
+
+add_stopwords(<DATA>);
+
+all_pod_files_spelling_ok();
+
+__DATA__
+Marc
+Mims
+BLOBs
+FS
+resultset
Added: DBIx-Class-InflateColumn-FS/1.000/trunk/t/99-pod_syntax.t
===================================================================
--- DBIx-Class-InflateColumn-FS/1.000/trunk/t/99-pod_syntax.t (rev 0)
+++ DBIx-Class-InflateColumn-FS/1.000/trunk/t/99-pod_syntax.t 2008-10-07 02:01:09 UTC (rev 4898)
@@ -0,0 +1,11 @@
+#!perl -wT
+use strict;
+use warnings;
+use Test::More;
+
+plan skip_all => 'set TEST_AUTHOR to enable this test' unless $ENV{TEST_AUTHOR};
+
+eval 'use Test::Pod 1.00';
+plan skip_all => 'Test::Pod 1.00 not installed' if $@;
+
+all_pod_files_ok();
More information about the Bast-commits
mailing list