/usr/share/perl5/URI/Namespace.pm is in liburi-namespacemap-perl 0.06-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | package URI::Namespace;
use Moose;
use Moose::Util::TypeConstraints;
use URI;
=head1 NAME
URI::Namespace - A namespace URI class with autoload methods
=head1 SYNOPSIS
use URI::Namespace;
my $foaf = URI::Namespace->new( 'http://xmlns.com/foaf/0.1/' );
print $foaf->as_string;
print $foaf->name;
=head1 DESCRIPTION
This module provides an object with a URI attribute, typically used
prefix-namespace pairs, typically used in XML, RDF serializations,
etc. The local part can be used as a method, these are autoloaded.
=head1 METHODS
=over
=item C<< new ( $string | URI ) >>
This is the constructor. You may pass a string with a URI or a URI object.
=item C<< uri >>
Returns a L<URI> object with the namespace URI.
=back
The following methods from L<URI> can be used on an URI::Namespace object: C<as_string>, C<as_iri>, C<canonical>, C<eq>, C<abs>, C<rel>.
One important usage for this module is to enable you to create L<URI>s for full URIs, e.g.:
print $foaf->Person->as_string;
will return
http://xmlns.com/foaf/0.1/Person
=head1 FURTHER DETAILS
See L<URI::NamespaceMap> for further details about authors, license, etc.
=cut
around BUILDARGS => sub {
my ($next, $self, @parameters) = @_;
return $self->$next(@_) if ((@parameters > 1) || (ref($parameters[0]) eq 'HASH'));
return { uri => $parameters[0] };
};
class_type 'URI';
coerce 'URI' => from 'Str' => via { URI->new($_) };
has uri => (
is => 'ro',
isa => 'URI',
coerce => 1,
required => 1,
handles => ['as_string', 'as_iri', 'canonical', 'eq', 'abs', 'rel']
);
our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
my ($name) = $AUTOLOAD =~ /::(\w+)$/;
return URI->new($self->uri . "$name");
}
no Moose::Util::TypeConstraints;
no Moose;
__PACKAGE__->meta->make_immutable();
1;
__END__
|