Index: /trunk/DataStore/MANIFEST
===================================================================
--- /trunk/DataStore/MANIFEST	(revision 6474)
+++ /trunk/DataStore/MANIFEST	(revision 6475)
@@ -6,4 +6,5 @@
 Build.PL
 Makefile.PL
+lib/DataStore/File/Parser.pm
 lib/DataStore/FileSet/Parser.pm
 t/00_distribution.t
Index: /trunk/DataStore/lib/DataStore/File/Parser.pm
===================================================================
--- /trunk/DataStore/lib/DataStore/File/Parser.pm	(revision 6475)
+++ /trunk/DataStore/lib/DataStore/File/Parser.pm	(revision 6475)
@@ -0,0 +1,151 @@
+# Copyright (C) 2006  Joshua Hoblitt
+#
+# $Id: Parser.pm,v 1.1 2006-02-24 03:14:29 jhoblitt Exp $
+
+package DataStore::File::Parser;
+
+use strict;
+use warnings;
+
+use vars qw($VERSION);
+$VERSION = '0.01';
+
+use Carp qw( carp );
+use Params::Validate qw( validate_pos SCALAR);
+
+my $std_field = qr/^[a-z0-9-_.]+$/;
+my %known_types = map { $_ => 1 } qw( chip );
+
+=pod
+
+=head1 NAME
+
+DataStore::File::Parser - parses the DataStore 'File list' format
+
+=head1 SYNOPSIS
+
+    use DataStore::File::Parser;
+
+    my $parser = DataStore::File::Parser->new;
+
+=head1 DESCRIPTION
+
+=head1 USAGE
+
+=head2 Import Parameters
+
+This module accepts no arguments to it's C<import> method and exports no
+I<symbols>.
+
+=head2 Methods
+
+=head3 Constructors
+
+=over 4
+
+=item * C<new()>
+
+Basic constructor.
+
+Accepts no arguments and returns a L<DataStore::File::Parser> object.
+
+=cut
+
+sub new
+{
+    my $class = shift;
+
+    my $self = bless {}, ref $class || $class;
+
+    return $self;
+}
+
+
+=back
+
+=head3 Object Methods
+
+=over 4
+
+=item * C<parse()>
+
+=cut
+
+sub parse
+{
+    my $self = shift;
+
+    my ($doc) = validate_pos(@_,
+        {
+            type    => SCALAR,
+            regex   => qr/\S+/, # string with atleast 1 non WS char
+        }
+    );
+
+    my @data;
+    my $lineno = 1;
+LINE: foreach my $line (split /\n/, $doc) {
+        # blank lines
+        next LINE if $line =~ /^\s*$/;
+
+        # comment lines   
+        next LINE if $line =~ /^\s*\#/;
+
+        my @fields = split /\|/, $line;
+
+        # at least fileid, bytes, md5sum, and type fields are required
+
+        if (scalar @fields < 4) {
+            carp "line $lineno: not enough fields: $line";
+            next LINE;
+        }
+
+        my ($fileid, $bytes, $md5sum, $type) = @fields;
+
+        # validate format of filed and type
+        foreach my $field ($fileid, $type) {
+            unless ($field =~ $std_field) {
+                carp "line $lineno: field $field:"
+                   . " does not conform to $std_field: $line";
+                next LINE;
+            }
+        }
+
+        # validate format of bytes
+
+        # validate format of md5sum
+#        unless ($datetime =~ $time_field) {
+#            carp "line $lineno: field $datetime:"
+#               . " does not conform to $time_field";
+#            next LINE;
+#        }
+#
+#        unless (exists $known_types{$type}) {
+#            carp "line $lineno: type $type unknown: $line";
+#            next LINE;
+#        } 
+#
+        unshift @data, DataStore::File::Record->new({
+            fileid  => $fileid,
+            bytes   => $bytes,
+            md5sum  => $md5sum,
+            type    => $type,
+        });
+    } continue {
+        $lineno++;
+    }
+
+    return @data ? \@data : undef;
+}
+
+package DataStore::File::Record;
+
+use base qw( Class::Accessor::Fast );
+
+use vars qw( @BASE_FIELDS );
+
+@BASE_FIELDS = qw( filed bytes md5sum type );
+
+1;
+
+__END__
Index: /trunk/DataStore/t/01_load.t
===================================================================
--- /trunk/DataStore/t/01_load.t	(revision 6474)
+++ /trunk/DataStore/t/01_load.t	(revision 6475)
@@ -3,6 +3,7 @@
 # t/001_load.t - check module loading and create testing directory
 
-use Test::More tests => 1;
+use Test::More tests => 2;
 
+BEGIN { use_ok( 'DataStore::File::Parser' ); }
 BEGIN { use_ok( 'DataStore::FileSet::Parser' ); }
 
