Changeset 6501
- Timestamp:
- Feb 27, 2006, 5:03:34 PM (20 years ago)
- Location:
- trunk/DataStore
- Files:
-
- 3 added
- 7 edited
-
MANIFEST (modified) (1 diff)
-
lib/DataStore/File.pm (added)
-
lib/DataStore/File/Parser.pm (modified) (4 diffs)
-
lib/DataStore/FileSet.pm (added)
-
lib/DataStore/FileSet/Parser.pm (modified) (3 diffs)
-
lib/DataStore/Product.pm (added)
-
lib/DataStore/Record.pm (modified) (4 diffs)
-
t/01_load.t (modified) (1 diff)
-
t/02_fileset_parse.t (modified) (3 diffs)
-
t/03_file_parse.t (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataStore/MANIFEST
r6492 r6501 7 7 README 8 8 Todo 9 lib/DataStore/File.pm 9 10 lib/DataStore/File/Parser.pm 11 lib/DataStore/FileSet.pm 10 12 lib/DataStore/FileSet/Parser.pm 13 lib/DataStore/Product.pm 14 lib/DataStore/Record.pm 11 15 t/00_distribution.t 12 16 t/01_load.t -
trunk/DataStore/lib/DataStore/File/Parser.pm
r6499 r6501 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: Parser.pm,v 1. 5 2006-02-27 22:32:00jhoblitt Exp $3 # $Id: Parser.pm,v 1.6 2006-02-28 03:02:12 jhoblitt Exp $ 4 4 5 5 package DataStore::File::Parser; … … 14 14 15 15 use Carp qw( carp ); 16 use DataStore:: Record;17 use Params::Validate qw( validate _pos SCALAR);16 use DataStore::File; 17 use Params::Validate qw( validate validate_pos SCALAR ); 18 18 19 19 my $std_field = qr/^[a-z0-9-_.]+$/; … … 63 63 my $class = shift; 64 64 65 my $self = bless {}, ref $class || $class; 65 my %p = validate(@_, 66 { 67 base_uri => { 68 type => SCALAR, 69 callbacks => { 70 'is valid http uri' => sub { is_http_uri($_[0]) }, 71 }, 72 default => 'http://example.org/', 73 }, 74 }, 75 ); 76 77 my $self = bless \%p, ref $class || $class; 66 78 67 79 return $self; … … 141 153 142 154 # fifo 143 push @data, DataStore:: Record::File->new({155 push @data, DataStore::File->new({ 144 156 fileid => $fileid, 145 157 bytes => $bytes, 146 158 md5sum => $md5sum, 147 159 type => $type, 160 uri => $self->base_uri . $fileid, 148 161 }); 149 162 } continue { -
trunk/DataStore/lib/DataStore/FileSet/Parser.pm
r6499 r6501 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: Parser.pm,v 1. 6 2006-02-27 22:32:00jhoblitt Exp $3 # $Id: Parser.pm,v 1.7 2006-02-28 03:02:12 jhoblitt Exp $ 4 4 5 5 package DataStore::FileSet::Parser; … … 15 15 use Carp qw( carp ); 16 16 use Data::Validate::URI qw( is_http_uri ); 17 use DataStore:: Record;17 use DataStore::FileSet; 18 18 use Params::Validate qw( validate validate_pos SCALAR); 19 19 … … 152 152 153 153 # fifo 154 push @data, DataStore:: Record::FileSet->new({154 push @data, DataStore::FileSet->new({ 155 155 fileset => $fileset, 156 156 datetime => $datetime, 157 157 type => $type, 158 uri => $self->base_uri . $fileset ,158 uri => $self->base_uri . $fileset . '/', 159 159 }); 160 160 } continue { -
trunk/DataStore/lib/DataStore/Record.pm
r6499 r6501 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: Record.pm,v 1. 1 2006-02-27 22:32:00jhoblitt Exp $3 # $Id: Record.pm,v 1.2 2006-02-28 03:02:12 jhoblitt Exp $ 4 4 5 5 package DataStore::Record; … … 15 15 use Carp qw( carp ); 16 16 use Data::Validate::URI qw( is_http_uri ); 17 use Params::Validate qw( validate validate_pos SCALAR);17 use Params::Validate qw( validate_with validate SCALAR ); 18 18 19 19 use vars qw( @BASE_FIELDS ); … … 44 44 =head2 Methods 45 45 46 =head3 Constructors 47 48 =over 4 49 50 =cut 51 52 sub new 53 { 54 my $class = shift; 55 56 my %p = validate_with( 57 params => \@_, 58 spec => { 59 uri => { 60 type => SCALAR, 61 callbacks => { 62 'is valid http uri' => sub { is_http_uri($_[0]) }, 63 }, 64 default => 'http://example.org/', 65 }, 66 }, 67 allow_extra => 1, 68 ); 69 70 my $self = bless { uri => $p{uri} }, ref $class || $class; 71 72 return $self; 73 } 74 75 =back 76 46 77 =head3 Object Methods 47 78 … … 52 83 =cut 53 84 54 package DataStore::Record::FileSet;55 56 use base qw( DataStore::Record );57 58 use vars qw( @BASE_FIELDS );59 60 @BASE_FIELDS = qw( fileset datetime type );61 62 __PACKAGE__->mk_accessors(@BASE_FIELDS);63 64 65 package DataStore::Record::File;66 67 use base qw( DataStore::Record );68 69 use vars qw( @BASE_FIELDS );70 71 @BASE_FIELDS = qw( fileid bytes md5sum type );72 73 __PACKAGE__->mk_accessors(@BASE_FIELDS);74 75 85 1; 76 86 -
trunk/DataStore/t/01_load.t
r6475 r6501 3 3 # t/001_load.t - check module loading and create testing directory 4 4 5 use Test::More tests => 2;5 use lib qw( ./lib ./t ); 6 6 7 use Test::More tests => 6; 8 9 BEGIN { use_ok( 'DataStore::File' ); } 7 10 BEGIN { use_ok( 'DataStore::File::Parser' ); } 11 BEGIN { use_ok( 'DataStore::FileSet' ); } 8 12 BEGIN { use_ok( 'DataStore::FileSet::Parser' ); } 9 13 BEGIN { use_ok( 'DataStore::Product' ); } 14 BEGIN { use_ok( 'DataStore::Record' ); } -
trunk/DataStore/t/02_fileset_parse.t
r6497 r6501 3 3 # Copyright (C) 2006 Joshua Hoblitt 4 4 # 5 # $Id: 02_fileset_parse.t,v 1. 4 2006-02-25 04:48:25jhoblitt Exp $5 # $Id: 02_fileset_parse.t,v 1.5 2006-02-28 03:02:12 jhoblitt Exp $ 6 6 7 7 use strict; … … 121 121 is(scalar @$results, 4, "correct number of item returned"); 122 122 123 isa_ok(@$results[0], 'DataStore::FileSet ::Record');123 isa_ok(@$results[0], 'DataStore::FileSet'); 124 124 is(@$results[0]->fileset, 'otis0123456', 'correct fileset'); 125 125 is(@$results[0]->datetime, '2006-01-01T00:03:04Z', 'correct datetime'); 126 126 is(@$results[0]->type, 'object', 'correct type'); 127 is(@$results[0]->uri, 'http://foo.com/otis0123456 ', 'correct uri');127 is(@$results[0]->uri, 'http://foo.com/otis0123456/', 'correct uri'); 128 128 129 isa_ok(@$results[1], 'DataStore::FileSet ::Record');129 isa_ok(@$results[1], 'DataStore::FileSet'); 130 130 is(@$results[1]->fileset, 'otis0123456', 'correct fileset'); 131 131 is(@$results[1]->datetime, '2006-01-01T00:03:04Z', 'correct datetime'); 132 132 is(@$results[1]->type, 'object', 'correct type'); 133 is(@$results[1]->uri, 'http://foo.com/otis0123456 ', 'correct uri');133 is(@$results[1]->uri, 'http://foo.com/otis0123456/', 'correct uri'); 134 134 135 isa_ok(@$results[2], 'DataStore::FileSet ::Record');135 isa_ok(@$results[2], 'DataStore::FileSet'); 136 136 is(@$results[2]->fileset, 'otis0123456', 'correct fileset'); 137 137 is(@$results[2]->datetime, '2006-01-01T00:03:04Z', 'correct datetime'); 138 138 is(@$results[2]->type, 'object', 'correct type'); 139 is(@$results[2]->uri, 'http://foo.com/otis0123456 ', 'correct uri');139 is(@$results[2]->uri, 'http://foo.com/otis0123456/', 'correct uri'); 140 140 141 isa_ok(@$results[3], 'DataStore::FileSet ::Record');141 isa_ok(@$results[3], 'DataStore::FileSet'); 142 142 is(@$results[3]->fileset, 'otis0123456', 'correct fileset'); 143 143 is(@$results[3]->datetime, '2006-01-01T00:03:04Z', 'correct datetime'); 144 144 is(@$results[3]->type, 'object', 'correct type'); 145 is(@$results[3]->uri, 'http://foo.com/otis0123456 ', 'correct uri');145 is(@$results[3]->uri, 'http://foo.com/otis0123456/', 'correct uri'); 146 146 } 147 147 … … 164 164 is(scalar @$results, 1, "correct number of item returned"); 165 165 166 isa_ok(@$results[0], 'DataStore::FileSet ::Record');166 isa_ok(@$results[0], 'DataStore::FileSet'); 167 167 is(@$results[0]->fileset, 'otis0123456', 'correct fileset'); 168 168 is(@$results[0]->datetime, '2006-01-01T00:03:04Z', 'correct datetime'); -
trunk/DataStore/t/03_file_parse.t
r6491 r6501 3 3 # Copyright (C) 2006 Joshua Hoblitt 4 4 # 5 # $Id: 03_file_parse.t,v 1. 2 2006-02-25 00:13:36jhoblitt Exp $5 # $Id: 03_file_parse.t,v 1.3 2006-02-28 03:02:12 jhoblitt Exp $ 6 6 7 7 use strict; … … 132 132 is(scalar @$results, 4, "correct number of item returned"); 133 133 134 isa_ok(@$results[0], 'DataStore::File ::Record');134 isa_ok(@$results[0], 'DataStore::File'); 135 135 is(@$results[0]->fileid, 'otis0123456.01', 'correct fileid'); 136 136 is(@$results[0]->bytes, '83002312', 'correct datetime'); … … 138 138 is(@$results[0]->type, 'chip', 'correct type'); 139 139 140 isa_ok(@$results[1], 'DataStore::File ::Record');140 isa_ok(@$results[1], 'DataStore::File'); 141 141 is(@$results[1]->fileid, 'otis0123456.02', 'correct fileid'); 142 142 is(@$results[1]->bytes, '83002312', 'correct datetime'); … … 144 144 is(@$results[1]->type, 'chip', 'correct type'); 145 145 146 isa_ok(@$results[2], 'DataStore::File ::Record');146 isa_ok(@$results[2], 'DataStore::File'); 147 147 is(@$results[2]->fileid, 'otis0123456.03', 'correct fileid'); 148 148 is(@$results[2]->bytes, '83002312', 'correct datetime'); … … 150 150 is(@$results[2]->type, 'chip', 'correct type'); 151 151 152 isa_ok(@$results[3], 'DataStore::File ::Record');152 isa_ok(@$results[3], 'DataStore::File'); 153 153 is(@$results[3]->fileid, 'otis0123456.04', 'correct fileid'); 154 154 is(@$results[3]->bytes, '83002312', 'correct datetime'); … … 175 175 is(scalar @$results, 1, "correct number of item returned"); 176 176 177 isa_ok(@$results[0], 'DataStore::File ::Record');177 isa_ok(@$results[0], 'DataStore::File'); 178 178 is(@$results[0]->fileid, 'otis0123456.01', 'correct fileid'); 179 179 is(@$results[0]->bytes, '83002312', 'correct datetime');
Note:
See TracChangeset
for help on using the changeset viewer.
