NAME

Path::Resource - URI/Path::Class combination.

VERSION

Version 0.05

SYNOPSIS

use Path::Resource;

# Map a resource on the local disk to a URI.
# Its (disk) directory is "/var/dir" and its uri is "http://hostname/loc"
my $rsc = new Path::Resource dir => "/var/dir", uri => "http://hostname/loc";
# uri: http://hostname/loc 
# dir: /var/dir

my $apple_rsc = $rsc->child("apple");
# uri: http://hostname/loc/apple
# dir: /var/dir/apple

my $banana_txt_rsc = $apple_rsc->child("banana.txt");
# uri: http://hostname/loc/apple/banana.txt
# file: /var/dir/apple/banana.txt

my $size = -s $banana_txt_rsc->file;

redirect($banana_txt_rsc->uri);
Path::Resource->new
$rsc->path
$rsc->path( <part>, [ <part>, ..., <part> ] )

Return a clone of $rsc->path based on $rsc->path and any optional <part> passed through

my $rsc = Path::Resource->new(path => "b/c");

# $path is "b/c"
my $path = $rsc->path;

# $path is "b/c/d"
my $path = $rsc->path("d");
$rsc->clone
$rsc->clone( <path> )

Return a Path::Resource object that is a copy of $rsc

The optional argument will change (not append) the path of the cloned object

$rsc->child( <part>, [ <part>, ..., <part> ] )

Return a clone Path::Resource object whose path is the child of $rsc->path

my $rsc = Path::Resource->new(dir => "/a", path => "b");

# $rsc->path is "b/c/d.tmp"
$rsc = $rsc->child("c/d.tmp");
$rsc->parent

Return a clone Path::Resource object whose path is the parent of $rsc->path

my $rsc = Path::Resource->new(dir => "/a", path => "b/c");

# $rsc->path is "b"
$rsc = $rsc->parent;

# $rsc->path is ""
$rsc = $rsc->parent;

# $dir is "/a/f"
my $dir = $rsc->parent->parent->dir("f");
$rsc->loc
$rsc->loc( <part>, [ <part>, ..., <part> ] )

Return a Path::Abstract object based on the path part of $rsc->base->uri ($rsc->base->loc), $rsc->path, and any optional <part> passed through

my $rsc = Path::Resource->new(uri => "http://example.com/a", path => "b/c");

# $loc is "/a/b/c"
my $loc = $rsc->loc;

# $dir is "/a/b/c/d.tmp"
$loc = $rsc->loc("d.tmp");
$rsc->uri
$rsc->uri( <part>, [ <part>, ..., <part> ] )

Return a URI object based on $rsc->base->uri, $rsc->path, and any optional <part> passed through

my $rsc = Path::Resource->new(uri => "http://example.com/a", path => "b/c");

# $uri is "http://example.com/a/b/c"
my $uri = $rsc->uri;

# $uri is "http://example.com/a/b/c/d.tmp"
$uri = $rsc->uri("d.tmp");

# $uri is "https://example.com/a/b/c/d.tmp"
$uri->scheme("https");
$rsc->file
$rsc->file( [ <part>, <part>, ..., <part> ] )

Return a Path::Class::File object based on $rsc->base->dir, $rsc->path, and any optional <part> passed through

my $rsc = Path::Resource->new(dir => "/a", path => "b");
$rsc = $rsc->child("c/d.tmp");

# $file is "/a/b/c/d.tmp"
my $file = $rsc->file;

# $file is "/a/b/c/d.tmp/e.txt"
$file = $rsc->file(qw/ e.txt /);
$rsc->dir
$rsc->dir( <part>, [ <part>, ..., <part> ] )

Return a Path::Class::Dir object based on $rsc->base->dir, $rsc->path, and any optional <part> passed through

my $rsc = Path::Resource->new(dir => "/a", path => "b");
$rsc = $rsc->child("c/d.tmp");

# $dir is "/a/b/c/d.tmp"
my $dir = $rsc->file;

# $dir is "/a/b/c/d.tmp/e.tmp"
$dir = $rsc->file(qw/ e.tmp /);
$rsc->base

Return the Path::Resource::Base object for $rsc

AUTHOR

Robert Krimen, <rkrimen at cpan.org>

BUGS

Please report any bugs or feature requests to bug-path-resource at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Path-Resource. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Path::Resource

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2007 Robert Krimen, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.