IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15020


Ignore:
Timestamp:
Sep 25, 2007, 1:37:44 PM (19 years ago)
Author:
jhoblitt
Message:

convert DataStore::Product to use URIs that end as /index.txt$ instead of /$

Location:
trunk/DataStore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataStore/lib/DataStore/FileSet/Parser.pm

    r7951 r15020  
    11# Copyright (C) 2006  Joshua Hoblitt
    22#
    3 # $Id: Parser.pm,v 1.13 2006-07-22 01:17:33 smalle Exp $
     3# $Id: Parser.pm,v 1.14 2007-09-25 23:37:44 jhoblitt Exp $
    44
    55package DataStore::FileSet::Parser;
     
    8989                    'is valid http uri' =>
    9090                        sub { is_uri($_[0]) and $_[0] =~ /^http:/ },
    91                     'uri ends with /'   => sub { $_[0] =~ m|/$| },
     91                    'uri ends with /index.txt' => sub { $_[0] =~ m|/index.txt$| },
    9292                },
    93                 default =>  'http://example.org/',
     93                default =>  'http://example.org/index.txt',
    9494            },
    9595        },
    9696    );
    9797
    98     my $self = bless \%p, ref $class || $class;
     98    my $self = bless {}, ref $class || $class;
     99
     100    $p{base_uri} =~ qr|(.*?/)index.txt|;
     101
     102    $self->{base_uri} = $1;
    99103
    100104    return $self;
  • trunk/DataStore/lib/DataStore/Product.pm

    r7951 r15020  
    11# Copyright (C) 2006  Joshua Hoblitt
    22#
    3 # $Id: Product.pm,v 1.8 2006-07-22 01:17:33 smalle Exp $
     3# $Id: Product.pm,v 1.9 2007-09-25 23:37:44 jhoblitt Exp $
    44
    55package DataStore::Product;
     
    102102                type        => SCALAR,
    103103                callbacks   => {
    104                     'is valid uri dirname'   => sub { $_[0] =~ m|/$| },
     104                    'uri ends with /index.txt' => sub { $_[0] =~ m|/index.txt$| },
    105105                }
    106106            },
  • trunk/DataStore/t/02_fileset_parse.t

    r8722 r15020  
    33# Copyright (C) 2006  Joshua Hoblitt
    44#
    5 # $Id: 02_fileset_parse.t,v 1.8 2006-08-31 22:58:34 jhoblitt Exp $
     5# $Id: 02_fileset_parse.t,v 1.9 2007-09-25 23:37:44 jhoblitt Exp $
    66
    77use strict;
     
    115115END
    116116    my $parser  = DataStore::FileSet::Parser->new(
    117         base_uri => 'http://foo.com/'
     117        base_uri => 'http://foo.com/index.txt'
    118118    );
    119119    my @results = $parser->parse($example1);
     
    132132END
    133133    my $parser  = DataStore::FileSet::Parser->new(
    134         base_uri => 'http://foo.com/'
     134        base_uri => 'http://foo.com/index.txt'
    135135    );
    136136    my $results = $parser->parse($example1);
  • trunk/DataStore/t/05_product.t

    r8722 r15020  
    33# Copyright (C) 2006  Joshua Hoblitt
    44#
    5 # $Id: 05_product.t,v 1.5 2006-08-31 22:58:34 jhoblitt Exp $
     5# $Id: 05_product.t,v 1.6 2007-09-25 23:37:44 jhoblitt Exp $
    66
    77use strict;
     
    1010use lib qw( ./lib ./t );
    1111
    12 use Test::More tests => 22;
     12use Test::More tests => 23;
    1313
    1414=head1 NAME
     
    3232
    3333{
    34     my $dsp = DataStore::Product->new( uri => 'http://example.org/' );
     34    my $dsp = DataStore::Product->new( uri => 'http://example.org/index.txt' );
    3535
    3636    isa_ok($dsp, 'DataStore::Product');
     
    3939{
    4040    my $dsp = DataStore::Product->new(
    41         uri             => 'http://example.org/',
     41        uri             => 'http://example.org/index.txt',
    4242        last_fileset    => '12buckelyourshoe',
    4343    );
     
    4747
    4848eval {
    49     my $dsp = DataStore::Product->new( uri => 'http://example.org/', foo => 1 );
     49    my $dsp = DataStore::Product->new( uri => 'http://example.org/index.txt', foo => 1 );
    5050};
    5151like($@, qr/not listed in the validation options/,
     
    5454eval {
    5555    my $dsp = DataStore::Product->new(
    56         uri             => 'http://example.org/',
     56        uri             => 'http://example.org/index.txt',
    5757        last_fileset    => '12buckelyourshoe',
    5858        foo => 1,
     
    6565    my $dsp = DataStore::Product->new( uri => 'http://example.org' );
    6666};
    67 like($@, qr/is valid uri dirname/,
    68     '->new() fails when uri param does not end with /');
     67like($@, qr/uri ends with \/index.txt/,
     68    '->new() fails when uri param does not end with /index.txt');
    6969
    7070eval {
    71     my $dsp = DataStore::Product->new( uri => '://example.org' );
     71    my $dsp = DataStore::Product->new( uri => 'http://example.org/index.html' );
     72};
     73like($@, qr/uri ends with \/index.txt/,
     74    '->new() fails when uri param does not end with /index.txt');
     75
     76eval {
     77    my $dsp = DataStore::Product->new( uri => '://example.org/index.txt' );
    7278};
    7379like($@, qr/is valid http uri/,
     
    7682eval {
    7783    my $dsp = DataStore::Product->new(
    78         uri             => 'http://example.org/',
     84        uri             => 'http://example.org/index.txt',
    7985        last_fileset    => '++12buckelyourshoe',
    8086    );
     
    130136    print $server->Start(), "\n";
    131137
    132     $server->RegisterURL('/', \&bar);
     138    $server->RegisterURL('/index.txt', \&bar);
    133139    $server->Process();  # Run forever
    134140
     
    140146
    141147{
    142     my $dsp = DataStore::Product->new( uri => "http://localhost:$port/" );
     148    my $dsp = DataStore::Product->new( uri => "http://localhost:$port/index.txt" );
    143149
    144150    isa_ok($dsp->request, 'DataStore::Response');
     
    146152
    147153{
    148     my $dsp = DataStore::Product->new( uri => "http://localhost:$port/" );
     154    my $dsp = DataStore::Product->new( uri => "http://localhost:$port/index.txt" );
    149155
    150156    my $dsr = $dsp->request;
     
    168174
    169175eval {
    170     my $dsp = DataStore::Product->new( uri => 'http://example.org/' );
     176    my $dsp = DataStore::Product->new( uri => 'http://example.org/index.txt' );
    171177
    172178    $dsp->request( foo => 1 );
  • trunk/DataStore/t/08_response.t

    r7951 r15020  
    33# Copyright (C) 2006  Joshua Hoblitt
    44#
    5 # $Id: 08_response.t,v 1.2 2006-07-22 01:17:34 smalle Exp $
     5# $Id: 08_response.t,v 1.3 2007-09-25 23:37:44 jhoblitt Exp $
    66
    77use strict;
     
    4343        status_line => 'foo',
    4444        data        => 'bar',
    45         request     => DataStore::Product->new( uri => 'http://example.org/' ),
     45        request     => DataStore::Product->new( uri => 'http://example.org/index.txt' ),
    4646    );
    4747
     
    5555        status_line => 'foo',
    5656        data        => 'bar',
    57         request     => DataStore::Product->new( uri => 'http://example.org/' ),
     57        request     => DataStore::Product->new( uri => 'http://example.org/index.txt' ),
    5858        foo         => 1,
    5959    );
Note: See TracChangeset for help on using the changeset viewer.