VERSION

Version 0.032

SYNOPSIS

    my $uri = URI::SmartURI->new(
        'http://host/foo/',
        { reference => 'http://host/bar/' }
    );

    my $hostless = $uri->hostless; # '/foo/'

    $hostless->absolute; # 'http://host/foo/'

    $uri->relative; # '../foo/'

DESCRIPTION

This is a sort of \*(L"subclass\*(R" of \s-1URI\s0 using delegation with some extra methods, all the methods that work for \s-1URI\s0s will work on these objects as well.

It's similar in spirit to URI::WithBase.

It's also completely safe to subclass for your own use.

CONSTRUCTORS

Takes a uri $str and an optional scheme or hashref with a reference uri (for computing relative/absolute URIs) and an optional scheme.

my $uri = URI::SmartURI->new('http://dev.catalyst.perl.org/');

my $uri = URI::SmartURI->new('/dev.catalyst.perl.org/new-wiki/', 'http');

my $uri = URI::SmartURI->new( 'http://search.cpan.org/~jrockway/Catalyst-Manual-5.701003/', { reference => 'http://search.cpan.org/' } );

The object returned will be blessed into a scheme-specific subclass, based on the class of the underlying $uri->obj (\s-1URI\s0 object.) For example, URI::SmartURI::http, which derives from URI::SmartURI (or $uri->factory_class if you're subclassing.) Proxy for \s-1URI\s0->new_abs

URI::SmartURI->newlocal($filename, [$os])

Proxy for \s-1URI::URL\s0->newlocal

METHODS

Returns the \s-1URI\s0 with the scheme and host parts stripped. Accessor for the reference \s-1URI\s0 (for relative/absolute below.) Returns the \s-1URI\s0 relative to the reference \s-1URI\s0. Returns the absolute \s-1URI\s0 using the reference \s-1URI\s0 as base. stringification works, just like with \s-1URI\s0s

==

and == does as well Explicit equality check to another \s-1URI\s0, can be used as URI::SmartURI::eq($uri1, $uri2) as well. Accessor for the \s-1URI\s0 object methods are delegated to. The class whose constructor was called to create the $uri object, usually URI::SmartURI or your own subclass. This is used to call class (rather than object) methods.

INTERNAL METHODS

These are used internally by SmartURI, and are not interesting for general use, but may be useful for writing subclasses. Returns a hashref of options for the $uri (reference and scheme.) Converts, eg., \*(L"URI::http\*(R" to \*(L"URI::SmartURI::http\*(R". Creates a new proxy class class for a \s-1URI\s0 class, with all exports and constructor intact, and returns its name, which is made using _resolve_uri_class (above). Inflate any \s-1URI\s0 objects in @rray into URI::SmartURI objects, all other members pass through unharmed. $opts is a hashref of options to include in the objects created. Deflate any URI::SmartURI objects in @rray into the \s-1URI\s0 objects they are proxies for, all other members pass through unharmed.

MAGICAL IMPORT

On import with the \*(C`-import_uri_mods\*(C' flag it loads all the \s-1URI\s0 .pms into your class namespace.

This works:

use URI::SmartURI '-import_uri_mods'; use URI::SmartURI::WithBase; use URI::SmartURI::URL;

my $url = URI::SmartURI::URL->new(...); # URI::URL proxy

Even this works:

use URI::SmartURI '-import_uri_mods'; use URI::SmartURI::Escape qw(%escapes);

It even works with a subclass of URI::SmartURI.

I only wrote this functionality so that I could run the \s-1URI\s0 test suite without much modification, it has no real practical value.

BUGS

Please report any bugs or feature requests to \*(C`bug-uri-smarturi at rt.cpan.org\*(C', or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=URI-SmartURI <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=URI-SmartURI>. 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 URI::SmartURI

You can also look for information at:

  • \s-1RT:\s0 \s-1CPAN\s0's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=URI-SmartURI <http://rt.cpan.org/NoAuth/Bugs.html?Dist=URI-SmartURI>

  • AnnoCPAN: Annotated \s-1CPAN\s0 documentation http://annocpan.org/dist/URI-SmartURI <http://annocpan.org/dist/URI-SmartURI>

  • \s-1CPAN\s0 Ratings http://cpanratings.perl.org/d/URI-SmartURI <http://cpanratings.perl.org/d/URI-SmartURI>

  • Search \s-1CPAN\s0 http://search.cpan.org/dist/URI-SmartURI <http://search.cpan.org/dist/URI-SmartURI>

RELATED TO URI::SmartURI…

Catalyst::Plugin::SmartURI, \s-1URI\s0, URI::WithBase

ACKNOWLEDGEMENTS

Thanks to folks on freenode #perl for helping me out when I was getting stuck, Somni, revdiablo, PerlJam and others whose nicks I forget.

AUTHOR

Rafael Kitover, \*(C`<rkitover at cpan.org>\*(C'

COPYRIGHT & LICENSE

Copyright (c) 2008 Rafael Kitover

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