| 1 | package URI::crid; | ||||||||||||
| 2 | |||||||||||||
| 3 | 3 | require URI; | |||||||||||
| 4 | 3 | our @ISA=qw(URI); | |||||||||||
| 5 | |||||||||||||
| 6 | 3 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 3 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 3 | ▶ | use URI::Escape qw(uri_unescape); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | =head1 NAME | ||||||||||||
| 11 | |||||||||||||
| 12 | URI::crid - URI scheme as defined in RFC 4078 | ||||||||||||
| 13 | |||||||||||||
| 14 | =head1 VERSION | ||||||||||||
| 15 | |||||||||||||
| 16 | Version 0.01 | ||||||||||||
| 17 | |||||||||||||
| 18 | =cut | ||||||||||||
| 19 | |||||||||||||
| 20 | 3 | our $VERSION = '0.01'; | |||||||||||
| 21 | |||||||||||||
| 22 | =head1 SYNOPSIS | ||||||||||||
| 23 | |||||||||||||
| 24 | Allows you to break down and/or build up URIs of the scheme CRID (as used | ||||||||||||
| 25 | by the TV-Anytime standard to uniquely identify television and radio | ||||||||||||
| 26 | programmes. | ||||||||||||
| 27 | |||||||||||||
| 28 | use URI; | ||||||||||||
| 29 | |||||||||||||
| 30 | my $doctor_who = URI->new("crid://bbc.co.uk/b0074fly"); | ||||||||||||
| 31 | print "authority: " . $doctor_who->authority . $/; | ||||||||||||
| 32 | print "data: " . $doctor_who->data . $/; | ||||||||||||
| 33 | ... | ||||||||||||
| 34 | |||||||||||||
| 35 | =head1 METHODS | ||||||||||||
| 36 | |||||||||||||
| 37 | =head2 authority [AUTHORITY] | ||||||||||||
| 38 | |||||||||||||
| 39 | Returns (or sets) the organisation which owns this crid. This usually | ||||||||||||
| 40 | corresponds to the organisation's domain name. | ||||||||||||
| 41 | |||||||||||||
| 42 | =cut | ||||||||||||
| 43 | |||||||||||||
| 44 | sub authority | ||||||||||||
| 45 | 2 | ▶ | { | ||||||||||
|
Subroutine
authority: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||
| 46 | 2 | my $self = shift; | |||||||||||
| 47 | 2 | my $old = $self->opaque; | |||||||||||
| 48 | 2 | ▶ | if (@_) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 49 | 1 | my $data = ($old =~ m|//[^/]+/(.*)$|)[0]; | |||||||||||
| 50 | 1 | my $new = shift; | |||||||||||
| 51 | 1 | ▶ | $new = "" unless defined $new; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 52 | 1 | $self->opaque("//$new/$data"); | |||||||||||
| 53 | 1 | return $new; | |||||||||||
| 54 | } | ||||||||||||
| 55 | 1 | ▶ | $old = ($old =~ m|^//([^/]+)/?|)[0] || ''; | ||||||||||
|
Condition50%1/2
($old =~ m[^//([^/]+)/?])[0] || ''
MC/DC0%0/1
($old =~ m[^//([^/]+)/?])[0] || ''
($old =~ m[^//([^/]+)/?])[0]
Truth table50%1/2
A
A= ($old =~ m[^//([^/]+)/?])[0]
| |||||||||||||
| 56 | 1 | ▶ | return undef unless defined $old; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 57 | 1 | return uri_unescape($old); | |||||||||||
| 58 | } | ||||||||||||
| 59 | |||||||||||||
| 60 | =head2 data [DATA] | ||||||||||||
| 61 | |||||||||||||
| 62 | Returns (or sets) the unique identifier that this crid applies to. | ||||||||||||
| 63 | The author of a crid may decide for themselves what form this data | ||||||||||||
| 64 | takes, to best suit the application. | ||||||||||||
| 65 | |||||||||||||
| 66 | =cut | ||||||||||||
| 67 | |||||||||||||
| 68 | sub data | ||||||||||||
| 69 | 2 | ▶ | { | ||||||||||
|
Subroutine
data: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||
| 70 | 2 | my $self = shift; | |||||||||||
| 71 | 2 | my $old = $self->opaque; | |||||||||||
| 72 | 2 | ▶ | if (@_) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 73 | 1 | my $tmp = $old; | |||||||||||
| 74 | 1 | ▶ | $tmp = "/" unless defined $tmp; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 75 | 1 | ▶ | my $authority = ($old =~ m|^//([^/]+)/?|)[0] || ''; | ||||||||||
|
Condition50%1/2
($old =~ m[^//([^/]+)/?])[0] || ''
MC/DC0%0/1
($old =~ m[^//([^/]+)/?])[0] || ''
($old =~ m[^//([^/]+)/?])[0]
Truth table50%1/2
A
A= ($old =~ m[^//([^/]+)/?])[0]
| |||||||||||||
| 76 | 1 | my $new = shift; | |||||||||||
| 77 | 1 | ▶ | $new = "" unless defined $new; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 78 | 1 | $self->opaque("//$authority/$new"); | |||||||||||
| 79 | 1 | return $new; | |||||||||||
| 80 | } | ||||||||||||
| 81 | 1 | $old = ($old =~ m|//[^/]+/(.*)$|)[0]; | |||||||||||
| 82 | 1 | return uri_unescape($old); | |||||||||||
| 83 | } | ||||||||||||
| 84 | |||||||||||||
| 85 | 3 | 1; | |||||||||||
| 86 | |||||||||||||
| 87 | =head1 AUTHOR | ||||||||||||
| 88 | |||||||||||||
| 89 | Ali Craigmile, C<< <ali at hodgers.com> >> | ||||||||||||
| 90 | |||||||||||||
| 91 | =head1 BUGS | ||||||||||||
| 92 | |||||||||||||
| 93 | Please report any bugs or feature requests to C<bug-uri-crid at rt.cpan.org>, or through | ||||||||||||
| 94 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=URI-crid>. I will be notified, and then you'll | ||||||||||||
| 95 | automatically be notified of progress on your bug as I make changes. | ||||||||||||
| 96 | |||||||||||||
| 97 | |||||||||||||
| 98 | |||||||||||||
| 99 | |||||||||||||
| 100 | =head1 SUPPORT | ||||||||||||
| 101 | |||||||||||||
| 102 | You can find documentation for this module with the perldoc command. | ||||||||||||
| 103 | |||||||||||||
| 104 | perldoc URI::crid | ||||||||||||
| 105 | |||||||||||||
| 106 | |||||||||||||
| 107 | You can also look for information at: | ||||||||||||
| 108 | |||||||||||||
| 109 | =over 4 | ||||||||||||
| 110 | |||||||||||||
| 111 | =item * RT: CPAN's request tracker | ||||||||||||
| 112 | |||||||||||||
| 113 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=URI-crid> | ||||||||||||
| 114 | |||||||||||||
| 115 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||
| 116 | |||||||||||||
| 117 | L<http://annocpan.org/dist/URI-crid> | ||||||||||||
| 118 | |||||||||||||
| 119 | =item * CPAN Ratings | ||||||||||||
| 120 | |||||||||||||
| 121 | L<http://cpanratings.perl.org/d/URI-crid> | ||||||||||||
| 122 | |||||||||||||
| 123 | =item * Search CPAN | ||||||||||||
| 124 | |||||||||||||
| 125 | L<http://search.cpan.org/dist/URI-crid> | ||||||||||||
| 126 | |||||||||||||
| 127 | =back | ||||||||||||
| 128 | |||||||||||||
| 129 | |||||||||||||
| 130 | =head1 ACKNOWLEDGEMENTS | ||||||||||||
| 131 | |||||||||||||
| 132 | Gisle Aas C<< gaas@cpan.org >> for writing the base class URI. | ||||||||||||
| 133 | |||||||||||||
| 134 | =head1 COPYRIGHT & LICENSE | ||||||||||||
| 135 | |||||||||||||
| 136 | Copyright 2007 Ali Craigmile, all rights reserved. | ||||||||||||
| 137 | |||||||||||||
| 138 | This program is free software; you can redistribute it and/or modify it | ||||||||||||
| 139 | under the same terms as Perl itself. | ||||||||||||
| 140 | |||||||||||||
| 141 | |||||||||||||
| 142 | =cut | ||||||||||||
| 143 | |||||||||||||
| 144 | 3 | 1; # End of URI::crid | |||||||||||