Changeset 6603
- Timestamp:
- Mar 16, 2006, 11:44:58 AM (20 years ago)
- Location:
- trunk/DataStore/lib
- Files:
-
- 8 edited
-
DataStore.pm (modified) (3 diffs)
-
DataStore/File.pm (modified) (3 diffs)
-
DataStore/File/Parser.pm (modified) (7 diffs)
-
DataStore/FileSet.pm (modified) (2 diffs)
-
DataStore/FileSet/Parser.pm (modified) (8 diffs)
-
DataStore/Product.pm (modified) (2 diffs)
-
DataStore/Record.pm (modified) (2 diffs)
-
DataStore/Response.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataStore/lib/DataStore.pm
r6602 r6603 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: DataStore.pm,v 1. 1 2006-03-16 20:56:41jhoblitt Exp $3 # $Id: DataStore.pm,v 1.2 2006-03-16 21:44:57 jhoblitt Exp $ 4 4 5 5 package DataStore; … … 33 33 34 34 This is a convenience module so that that don't have to individualy load (C<use 35 ...;>) all of the common DataStore inteface modules. Please see the 36 POD of the individual modules for usage information. 35 ...;>) all of the common DataStore inteface modules. Please see the POD of the 36 individual modules for usage information. If this is your browsing of the 37 documentation you may want to start with L<DataStore::Product>. 37 38 38 39 =head1 USAGE … … 46 47 47 48 None. 49 50 =head1 EXAMPLE PROGRAM 51 52 #!/usr/bin/perl 53 54 use strict; 55 use warnings; 56 57 # loads DataStore::* 58 use DataStore; 59 60 my $dsp = DataStore::Product->new( 61 uri => 'http://example.org/productid/', 62 last_fileset => 'foobarbaz', 63 ); 64 65 # returns a DataStore::Response object 66 my $response = $dsp->request; 67 68 unless ($response->is_success) { 69 die $response->status; 70 } 71 72 # arrayref of DataStore::FileSet objects 73 my $filesets = $response->data; 74 75 # the query could be a success but still return no filesets 76 unless ($filesets) { 77 warn "no filesets returned"; 78 exit(0); 79 } 80 81 # returns a DataStore::Response object 82 my $response2 = @$filesets[0]->request; 83 84 unless ($response2->is_success) { 85 die $response2->status; 86 } 87 88 # arrayref of DataStore::File objects 89 my $files = $response->data; 90 91 # the query could be a success but still return no files (is that legal?) 92 unless (@$files) { 93 warn "no files returned"; 94 exit(0); 95 } 96 97 # requires a filename 98 my $response3 = @$files[0]->request( filename => '/dev/null' ); 99 unless ($response3->is_success) { 100 warn $response3->status; 101 die; 102 } 103 104 # $response3->data is '/dev/null' 48 105 49 106 =cut -
trunk/DataStore/lib/DataStore/File.pm
r6601 r6603 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: File.pm,v 1. 6 2006-03-16 02:47:09jhoblitt Exp $3 # $Id: File.pm,v 1.7 2006-03-16 21:44:58 jhoblitt Exp $ 4 4 5 5 package DataStore::File; … … 52 52 53 53 =head1 DESCRIPTION 54 55 This class I<isa> L<DataStore::Record> 54 56 55 57 =head1 USAGE … … 143 145 =over 4 144 146 145 =item * C<uri >146 147 Basic accessor. 148 149 =item * C<fileid >150 151 Basic accessor. 152 153 =item * C<bytes >154 155 Basic accessor. 156 157 =item * C<md5sum >158 159 Basic accessor. 160 161 =item * C<type >147 =item * C<uri()> 148 149 Basic accessor. 150 151 =item * C<fileid()> 152 153 Basic accessor. 154 155 =item * C<bytes()> 156 157 Basic accessor. 158 159 =item * C<md5sum()> 160 161 Basic accessor. 162 163 =item * C<type()> 162 164 163 165 Basic accessor. -
trunk/DataStore/lib/DataStore/File/Parser.pm
r6501 r6603 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: Parser.pm,v 1. 6 2006-02-28 03:02:12jhoblitt Exp $3 # $Id: Parser.pm,v 1.7 2006-03-16 21:44:58 jhoblitt Exp $ 4 4 5 5 package DataStore::File::Parser; … … 28 28 =head1 NAME 29 29 30 DataStore::File::Parser - parses the DataStore 'File list'format30 DataStore::File::Parser - parses the DataStore 'File' list format 31 31 32 32 =head1 SYNOPSIS … … 34 34 use DataStore::File::Parser; 35 35 36 my $parser = DataStore::File::Parser->new; 36 my $parser = DataStore::File::Parser->new( 37 base_uri => 'http://example.org/', 38 ); 39 40 my @data = $parser->parse($str); 41 or 42 my $data = $parser->parse($str); 43 37 44 38 45 =head1 DESCRIPTION 46 47 This class parses a DataStore listing of I<File>s into an array of L<DataStore::File> objects. 39 48 40 49 =head1 USAGE … … 55 64 Basic constructor. 56 65 57 Accepts no arguments and returns a L<DataStore::File::Parser> object. 66 my $parser = DataStore::File::Parser->new( 67 base_uri => 'http://example.org/', 68 ); 69 70 Accepts an optional hash and returns a L<DataStore::FileSet::Parser> object. 71 72 =over 4 73 74 =item * base_uri 75 76 The base of the URI to set in the created L<DataStore::File> objects. 77 78 This key is optional and defaults to C<http://example.org/>. 79 80 =back 58 81 59 82 =cut … … 87 110 =over 4 88 111 112 =item * C<base_uri()> 113 114 Basic accessor. 115 89 116 =item * C<parse()> 117 118 Accepts a string and returns a list in list context or an arrayref is scalar 119 context. An empty list or undef is returned if the string contained no rows. 90 120 91 121 =cut … … 98 128 { 99 129 type => SCALAR, 100 regex => qr/\S+/, # string with at least 1 non WS char130 regex => qr/\S+/, # string with at least 1 non WS char 101 131 } 102 132 ); … … 164 194 } 165 195 166 return @data ? \@data : undef; 196 return unless @data; 197 return wantarary ? @data : \@data; 167 198 } 168 199 200 =back 201 202 =head1 SEE ALSO 203 204 L<DataStore::File>, L<DataStore::FileSet::Parser> 205 206 =cut 207 169 208 1; 170 209 -
trunk/DataStore/lib/DataStore/FileSet.pm
r6601 r6603 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: FileSet.pm,v 1. 4 2006-03-16 02:47:09jhoblitt Exp $3 # $Id: FileSet.pm,v 1.5 2006-03-16 21:44:58 jhoblitt Exp $ 4 4 5 5 package DataStore::FileSet; … … 49 49 50 50 =head1 DESCRIPTION 51 52 This class I<isa> L<DataStore::Record> 51 53 52 54 =head1 USAGE -
trunk/DataStore/lib/DataStore/FileSet/Parser.pm
r6501 r6603 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: Parser.pm,v 1. 7 2006-02-28 03:02:12jhoblitt Exp $3 # $Id: Parser.pm,v 1.8 2006-03-16 21:44:58 jhoblitt Exp $ 4 4 5 5 package DataStore::FileSet::Parser; … … 20 20 my $time_field = qr/^ (\d{4})-(\d\d)-(\d\d) T (\d\d):(\d\d):(\d\d) Z $/x; 21 21 my $std_field = qr/^[a-z0-9-_.]+$/; 22 #my %known_types = map { $_ => 1 } qw( OBJECT DOMEFLAT SKYFLAT BIAS DARK );23 22 my %known_types = map { $_ => 1 } qw( object domeflat skyflat bias dark ); 24 23 … … 29 28 =head1 NAME 30 29 31 DataStore::FileSet::Parser - parses the DataStore ' list'format30 DataStore::FileSet::Parser - parses the DataStore 'FileSet' list format 32 31 33 32 =head1 SYNOPSIS … … 35 34 use DataStore::FileSet::Parser; 36 35 37 my $parser = DataStore::FileSet::Parser->new; 36 my $parser = DataStore::FileSet::Parser->new( 37 base_uri => 'http://example.org/', 38 ); 39 40 my @data = $parser->parse($str); 41 or 42 my $data = $parser->parse($str); 38 43 39 44 =head1 DESCRIPTION 45 46 This class parses a DataStore listing of I<FileSet>s into an array of L<DataStore::FileSet> objects. 40 47 41 48 =head1 USAGE … … 56 63 Basic constructor. 57 64 58 Accepts no arguments and returns a L<DataStore::FileSet::Parser> object. 65 my $parser = DataStore::FileSet::Parser->new( 66 base_uri => 'http://example.org/', 67 ); 68 69 Accepts an optional hash and returns a L<DataStore::FileSet::Parser> object. 70 71 =over 4 72 73 =item * base_uri 74 75 The base of the URI to set in the created L<DataStore::FileSet> objects. 76 77 This key is optional and defaults to C<http://example.org/>. 78 79 =back 59 80 60 81 =cut … … 88 109 =over 4 89 110 111 =item * C<base_uri()> 112 113 Basic accessor. 114 90 115 =item * C<parse()> 116 117 Accepts a string and returns a list in list context or an arrayref is scalar 118 context. An empty list or undef is returned if the string contained no rows. 91 119 92 120 =cut … … 99 127 { 100 128 type => SCALAR, 101 regex => qr/\S+/, # string with at least 1 non WS char129 regex => qr/\S+/, # string with at least 1 non WS char 102 130 } 103 131 ); … … 162 190 } 163 191 164 return @data ? \@data : undef; 192 return unless @data; 193 return wantarary ? @data : \@data; 165 194 } 166 195 196 =head1 SEE ALSO 197 198 L<DataStore::FileSet>, L<DataStore::File:Parser> 199 200 =cut 201 167 202 1; 168 203 -
trunk/DataStore/lib/DataStore/Product.pm
r6601 r6603 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: Product.pm,v 1. 4 2006-03-16 02:47:09jhoblitt Exp $3 # $Id: Product.pm,v 1.5 2006-03-16 21:44:58 jhoblitt Exp $ 4 4 5 5 package DataStore::Product; … … 48 48 49 49 =head1 DESCRIPTION 50 51 This class I<isa> L<DataStore::Record> 50 52 51 53 =head1 USAGE -
trunk/DataStore/lib/DataStore/Record.pm
r6583 r6603 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: Record.pm,v 1. 4 2006-03-14 22:40:15jhoblitt Exp $3 # $Id: Record.pm,v 1.5 2006-03-16 21:44:58 jhoblitt Exp $ 4 4 5 5 package DataStore::Record; … … 86 86 =item * C<request()> 87 87 88 This method must be overloaded in sub-classes. 89 88 90 =cut 89 91 -
trunk/DataStore/lib/DataStore/Response.pm
r6601 r6603 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: Response.pm,v 1. 2 2006-03-16 02:47:09jhoblitt Exp $3 # $Id: Response.pm,v 1.3 2006-03-16 21:44:58 jhoblitt Exp $ 4 4 5 5 package DataStore::Response; … … 46 46 47 47 =head1 DESCRIPTION 48 49 This class represent the return state of the C<request()> method in 50 L<DataStore::Record> sub-classes. 48 51 49 52 =head1 USAGE … … 142 145 =over 4 143 146 144 =item * C<uri >147 =item * C<uri()> 145 148 146 149 Basic accessor. 147 150 148 =item * C<code >151 =item * C<code()> 149 152 150 153 Basic accessor. 151 154 152 =item * C<status_line >155 =item * C<status_line()> 153 156 154 157 Basic accessor. 155 158 156 =item * C<data >159 =item * C<data()> 157 160 158 161 Basic accessor. 159 162 160 =item * C<request >163 =item * C<request()> 161 164 162 165 Basic accessor.
Note:
See TracChangeset
for help on using the changeset viewer.
