IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16203


Ignore:
Timestamp:
Jan 23, 2008, 12:27:51 PM (18 years ago)
Author:
jhoblitt
Message:

add Nebulous::Util::parse_neb_key()

Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous-Server/Build.PL

    r13388 r16203  
    8080    create_makefile_pl  => 'passthrough',
    8181    requires            => {
     82        'Class::Accessor::Fast' => 0,
    8283        'Config::YAML'          => '1.42',
     84        'DBD::mysql'            => '3.0007',
     85        'DBI'                   => '1.53',
     86        'File::ExtAttr'         => '1.03',
     87        'File::Spec::Functions' => 0,
     88        'Log::Log4perl'         => '0.48',
     89        'Net::Server::Daemonize'=> '0.05',
     90        'Params::Validate'      => '0.73',
     91        'SOAP::Lite'            => '0.69',
     92        'Sys::Statistics::Linux::DiskUsage' => '0.02',
    8393        'URI'                   => '1.30',
    84         'SOAP::Lite'            => '0.69',
    85         'Log::Log4perl'         => '0.48',
    86         'DBI'                   => '1.53',
    87         'DBD::mysql'            => '3.0007',
    88         'Class::Accessor::Fast' => 0,
    89         'Params::Validate'      => '0.73',
    90         'Net::Server::Daemonize'=> '0.05',
    91         'Sys::Statistics::Linux::DiskUsage' => '0.02',
    92         'File::ExtAttr'         => '1.03',
    9394    },
    9495    build_requires      => {
  • trunk/Nebulous-Server/Changes

    r16183 r16203  
    22
    330.06
     4    - add Nebulous::Util::parse_neb_key()
    45    - change bin/* scripts to conistently use --volume instead of --node,
    56      etc.
  • trunk/Nebulous-Server/MANIFEST

    r16183 r16203  
    110110t/63_client_stat.t
    111111t/64_client_find_objects.t
     112t/75_parse_neb_key.t
    112113t/90_nebclient.t
    113114t/TEST.PL
  • trunk/Nebulous/Build.PL

    r13388 r16203  
    8080    create_makefile_pl  => 'passthrough',
    8181    requires            => {
     82        'Class::Accessor::Fast' => 0,
    8283        'Config::YAML'          => '1.42',
     84        'DBD::mysql'            => '3.0007',
     85        'DBI'                   => '1.53',
     86        'File::ExtAttr'         => '1.03',
     87        'File::Spec::Functions' => 0,
     88        'Log::Log4perl'         => '0.48',
     89        'Net::Server::Daemonize'=> '0.05',
     90        'Params::Validate'      => '0.73',
     91        'SOAP::Lite'            => '0.69',
     92        'Sys::Statistics::Linux::DiskUsage' => '0.02',
    8393        'URI'                   => '1.30',
    84         'SOAP::Lite'            => '0.69',
    85         'Log::Log4perl'         => '0.48',
    86         'DBI'                   => '1.53',
    87         'DBD::mysql'            => '3.0007',
    88         'Class::Accessor::Fast' => 0,
    89         'Params::Validate'      => '0.73',
    90         'Net::Server::Daemonize'=> '0.05',
    91         'Sys::Statistics::Linux::DiskUsage' => '0.02',
    92         'File::ExtAttr'         => '1.03',
    9394    },
    9495    build_requires      => {
  • trunk/Nebulous/Changes

    r16183 r16203  
    22
    330.06
     4    - add Nebulous::Util::parse_neb_key()
    45    - change bin/* scripts to conistently use --volume instead of --node,
    56      etc.
  • trunk/Nebulous/MANIFEST

    r16183 r16203  
    110110t/63_client_stat.t
    111111t/64_client_find_objects.t
     112t/75_parse_neb_key.t
    112113t/90_nebclient.t
    113114t/TEST.PL
  • trunk/Nebulous/lib/Nebulous/Util.pm

    r13302 r16203  
    11# Copyright (c) 2004  Joshua Hoblitt
    22#
    3 # $Id: Util.pm,v 1.7 2007-05-08 02:27:42 jhoblitt Exp $
     3# $Id: Util.pm,v 1.8 2008-01-23 22:27:51 jhoblitt Exp $
    44
    55package Nebulous::Util;
     
    1212use base qw( Exporter );
    1313
     14use File::Spec::Functions;
    1415use Log::Log4perl qw( :levels );
    1516use URI::file;
     
    2223    _get_filehandle
    2324    _open_uri
     25    parse_neb_key
    2426);
    2527
     
    7880}
    7981
     82sub parse_neb_key
     83{
     84    my $text = shift;
     85
     86    # white space is not allowed
     87    if ($text =~ qr/\s+/) {
     88        die "keys and URIs may not contain whitespace";
     89    }
     90
     91    my $uri = URI->new($text);
     92    my $scheme = $uri->scheme;
     93    my $path = $uri->opaque;
     94   
     95    my $volume;
     96    # if this is a valid uri
     97    if (defined $scheme) {
     98        # if so, does it use the neb scheme?
     99        die "URI does not use the 'neb' scheme"
     100            unless $scheme eq 'neb';
     101
     102        # neb:path (not allowed)
     103        # neb://<volume name>/...
     104        # neb:/path... (leading '/' is stripped)
     105        # neb:///path... (same as neb:/path)
     106
     107        # volume specifier must be at least one character
     108        # strip off volume component if it exists
     109        $path =~ s|^//([^/]+)||;
     110        $volume = $1;
     111
     112        # require a leading slash if there is no volume name
     113        if ((not defined $volume) and (not $path =~ m|^/|)) {
     114            die "neb URI scheme requires a leading slash, eg. neb:/";
     115        }
     116    }
     117
     118    # strip leading slashes
     119    $path =~ s|^/+||;
     120
     121    # remove multiple /'s and trailing slashes
     122    $path = canonpath($path);
     123
     124    return ($path, $volume);
     125}
     126
    801271;
    81128
Note: See TracChangeset for help on using the changeset viewer.