URI-PathAbstract

 view release on metacpan or  search on metacpan

lib/URI/PathAbstract.pm  view on Meta::CPAN


=head2 $uri->rel

=head2 $uri->rel( [ <base> ] )

Returns a L<URI::PathAbstract> object that is the relative URI formed by comparing $uri and <base>

If <base> is not given, then $uri->base is used as the base

If <base> is not given and $uri->base does not exist, then a clone of $uri is returned

See L<URI> and L<URI::WithBase> for more C<rel> information

=cut

sub rel {
    my $self = shift;
    my $class = ref $self;
    my $base = shift || $self->base || return $self->clone;
    return $class->new(uri => $self->uri->rel("$base", @_), base => $base);
}

{

=head2 URI

See L<URI> for more information

=head2 ->scheme

=head2 ->fragment

=head2 ->as_string

=head2 ->canonical

=head2 ->eq

=head2 ->authority

=head2 ->query

=head2 ->query_form

=head2 ->query_keywords

=head2 ->userinfo

=head2 ->host

=head2 ->port

=head2 ->host_port

=head2 ->default_port

=cut

    no strict 'refs';

    for my $method (grep { ! /^\s*#/ } split m/\n/, <<_END_) {
scheme
fragment
as_string
canonical
eq
authority
query
query_form
query_keywords
userinfo
host
port
host_port
default_port
_END_
        *$method = sub {
            my $self = shift;
            return $self->{uri}->$method(@_);
        }
    }

#=head2 abs

#Returns a L<URI::PathAbstract> object

#=head2 rel

#Returns a L<URI::PathAbstract> object

#=cut

=head2 ->opaque

=head2 ->path_query

=head2 ->path_segments

=head2 Path::Abstract

See L<Path::Abstract> for more information

=head2 ->child

=head2 ->parent

=cut

    for my $method (grep { ! /^\s*#/ } split m/\n/, <<_END_) {
child
parent
_END_
        *$method = sub {
            my $self = shift;
            my $path = $self->{path}->$method(@_);
            my $clone = $self->clone;
            $clone->path($path);
            return $clone;
        }
    }

=head2 ->up

=head2 ->pop

=head2 ->down

=head2 ->push

=head2 ->to_tree

=head2 ->to_branch

=cut

    for my $method (grep { ! /^\s*#/ } split m/\n/, <<_END_) {
up
pop
down
push
to_tree
to_branch
#set
_END_
        *$method = sub {
            my $self = shift;
            my $path = $self->{path};
            my @result;
            if (wantarray) {
                my @result = $path->$method(@_);
            }
            else {
                $result[0] = $path->$method(@_);
            }
            $self->path($$path);
            return wantarray ? @result : $result[0];
        }
    }
    
=head2 ->list

=head2 ->first

=head2 ->last

=head2 ->is_empty

=head2 ->is_nil

=head2 ->is_root

=head2 ->is_tree

=head2 ->is_branch

=cut

    for my $method (grep { ! /^\s*#/ } split m/\n/, <<_END_) {
#get
list
first
last
is_empty
is_nil
is_root
is_tree
is_branch
_END_
        *$method = sub {
            my $self = shift;
            return $self->{path}->$method(@_);
        }
    }
}

=head1 SEE ALSO

L<URI>

L<URI::WithBase>

L<Path::Abstract>

L<Path::Resource>

L<URI::SmartURI>

=head1 AUTHOR

Robert Krimen, C<< <rkrimen at cpan.org> >>

=head1 SOURCE

You can contribute or fork this project via GitHub:

L<http://github.com/robertkrimen/uri-pathabstract/tree/master>

    git clone git://github.com/robertkrimen/uri-pathabstract.git URI-PathAbstract

=head1 BUGS

Please report any bugs or feature requests to C<bug-uri-pathabstract at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=URI-PathAbstract>.  I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.

=head1 SUPPORT

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

    perldoc URI::PathAbstract


You can also look for information at:

=over 4

=item * RT: CPAN's request tracker



( run in 0.806 second using v1.01-cache-2.11-cpan-5511b514fd6 )