line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
1426775
|
use 5.008; |
|
4
|
|
|
|
|
37
|
|
2
|
4
|
|
|
4
|
|
22
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
86
|
|
3
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
274
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Types::URI; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.007'; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
2383
|
use URI; |
|
4
|
|
|
|
|
20566
|
|
|
4
|
|
|
|
|
129
|
|
11
|
4
|
|
|
4
|
|
1932
|
use URI::file; |
|
4
|
|
|
|
|
20727
|
|
|
4
|
|
|
|
|
132
|
|
12
|
4
|
|
|
4
|
|
1862
|
use URI::data; |
|
4
|
|
|
|
|
8079
|
|
|
4
|
|
|
|
|
120
|
|
13
|
4
|
|
|
4
|
|
1780
|
use URI::WithBase; |
|
4
|
|
|
|
|
3626
|
|
|
4
|
|
|
|
|
116
|
|
14
|
4
|
|
|
4
|
|
1808
|
use URI::FromHash; |
|
4
|
|
|
|
|
26633
|
|
|
4
|
|
|
|
|
242
|
|
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
4
|
|
1509
|
use Type::Library -base, -declare => qw( Uri FileUri DataUri Iri ); |
|
4
|
|
|
|
|
71623
|
|
|
4
|
|
|
|
|
56
|
|
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
5548
|
use Types::Path::Tiny qw( Path ); |
|
4
|
|
|
|
|
297681
|
|
|
4
|
|
|
|
|
41
|
|
19
|
4
|
|
|
4
|
|
1805
|
use Types::Standard qw( InstanceOf ScalarRef HashRef Str ); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
24
|
|
20
|
4
|
|
|
4
|
|
5998
|
use Types::UUID qw( Uuid ); |
|
4
|
|
|
|
|
106700
|
|
|
4
|
|
|
|
|
53
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $AtteanIRI = InstanceOf['Attean::IRI']; |
23
|
|
|
|
|
|
|
my $TrineNode = InstanceOf['RDF::Trine::Node::Resource']; |
24
|
|
|
|
|
|
|
my $TrineNS = InstanceOf['RDF::Trine::Namespace']; |
25
|
|
|
|
|
|
|
my $XmlNS = InstanceOf['XML::Namespace']; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
__PACKAGE__->meta->add_type({ |
28
|
|
|
|
|
|
|
name => Iri, |
29
|
|
|
|
|
|
|
parent => InstanceOf['IRI'], |
30
|
|
|
|
|
|
|
# Need to define coercions below to break circularity of |
31
|
|
|
|
|
|
|
# Uri and Iri. |
32
|
|
|
|
|
|
|
}); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__PACKAGE__->meta->add_type({ |
35
|
|
|
|
|
|
|
name => Uri, |
36
|
|
|
|
|
|
|
parent => InstanceOf[qw/ URI URI::WithBase /], |
37
|
|
|
|
|
|
|
coercion => [ |
38
|
|
|
|
|
|
|
Uuid ,=> q{ "URI"->new("urn:uuid:$_") }, |
39
|
|
|
|
|
|
|
Str ,=> q{ "URI"->new($_) }, |
40
|
|
|
|
|
|
|
Path ,=> q{ "URI::file"->new($_) }, |
41
|
|
|
|
|
|
|
ScalarRef ,=> q{ do { my $u = "URI"->new("data:"); $u->data($$_); $u } }, |
42
|
|
|
|
|
|
|
HashRef ,=> q{ "URI"->new(URI::FromHash::uri(%$_)) }, |
43
|
|
|
|
|
|
|
$TrineNode ,=> q{ "URI"->new($_->uri_value) }, |
44
|
|
|
|
|
|
|
$TrineNS ,=> q{ "URI"->new($_->uri->uri_value) }, |
45
|
|
|
|
|
|
|
$XmlNS ,=> q{ "URI"->new($_->uri) }, |
46
|
|
|
|
|
|
|
Iri ,=> q{ "URI"->new($_->as_string) }, |
47
|
|
|
|
|
|
|
$AtteanIRI ,=> q{ "URI"->new($_->as_string) }, |
48
|
|
|
|
|
|
|
], |
49
|
|
|
|
|
|
|
}); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Iri->coercion->add_type_coercions( |
52
|
|
|
|
|
|
|
Uuid ,=> q{ do { require IRI; "IRI"->new("urn:uuid:$_") } }, |
53
|
|
|
|
|
|
|
Str ,=> q{ do { require IRI; "IRI"->new($_) } }, |
54
|
|
|
|
|
|
|
Path ,=> q{ do { require IRI; my $u = "URI::file"->new($_); "IRI"->new($u->as_string) } }, |
55
|
|
|
|
|
|
|
ScalarRef ,=> q{ do { require IRI; my $u = "URI"->new("data:"); $u->data($$_); "IRI"->new($u->as_string) } }, |
56
|
|
|
|
|
|
|
HashRef ,=> q{ do { require IRI; "IRI"->new(URI::FromHash::uri(%$_)) } }, |
57
|
|
|
|
|
|
|
$TrineNode ,=> q{ do { require IRI; "IRI"->new($_->uri_value) } }, |
58
|
|
|
|
|
|
|
$TrineNS ,=> q{ do { require IRI; "IRI"->new($_->uri->uri_value) } }, |
59
|
|
|
|
|
|
|
$XmlNS ,=> q{ do { require IRI; "IRI"->new($_->uri) } }, |
60
|
|
|
|
|
|
|
Uri ,=> q{ do { require IRI; "IRI"->new($_->as_string) } }, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__PACKAGE__->meta->add_type({ |
64
|
|
|
|
|
|
|
name => FileUri, |
65
|
|
|
|
|
|
|
parent => Uri, |
66
|
|
|
|
|
|
|
constraint => sub { $_->isa('URI::file') }, |
67
|
|
|
|
|
|
|
inlined => sub { InstanceOf->parameterize('URI::file')->inline_check($_[1]) }, |
68
|
|
|
|
|
|
|
coercion => [ |
69
|
|
|
|
|
|
|
Str ,=> q{ "URI::file"->new($_) }, |
70
|
|
|
|
|
|
|
Path ,=> q{ "URI::file"->new($_) }, |
71
|
|
|
|
|
|
|
HashRef ,=> q{ "URI"->new(URI::FromHash::uri(%$_)) }, |
72
|
|
|
|
|
|
|
$TrineNode ,=> q{ "URI"->new($_->uri_value) }, |
73
|
|
|
|
|
|
|
$TrineNS ,=> q{ "URI"->new($_->uri->uri_value) }, |
74
|
|
|
|
|
|
|
$XmlNS ,=> q{ "URI"->new($_->uri) }, |
75
|
|
|
|
|
|
|
$AtteanIRI ,=> q{ "URI"->new($_->as_string) }, |
76
|
|
|
|
|
|
|
Iri ,=> q{ "URI"->new($_->as_string) }, |
77
|
|
|
|
|
|
|
], |
78
|
|
|
|
|
|
|
}); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__PACKAGE__->meta->add_type({ |
81
|
|
|
|
|
|
|
name => DataUri, |
82
|
|
|
|
|
|
|
parent => Uri, |
83
|
|
|
|
|
|
|
constraint => sub { $_->isa('URI::data') }, |
84
|
|
|
|
|
|
|
inlined => sub { InstanceOf->parameterize('URI::data')->inline_check($_[1]) }, |
85
|
|
|
|
|
|
|
coercion => [ |
86
|
|
|
|
|
|
|
Str ,=> q{ do { my $u = "URI"->new("data:"); $u->data($_); $u } }, |
87
|
|
|
|
|
|
|
ScalarRef ,=> q{ do { my $u = "URI"->new("data:"); $u->data($$_); $u } }, |
88
|
|
|
|
|
|
|
HashRef ,=> q{ "URI"->new(URI::FromHash::uri(%$_)) }, |
89
|
|
|
|
|
|
|
$TrineNode ,=> q{ "URI"->new($_->uri_value) }, |
90
|
|
|
|
|
|
|
$TrineNS ,=> q{ "URI"->new($_->uri->uri_value) }, |
91
|
|
|
|
|
|
|
$XmlNS ,=> q{ "URI"->new($_->uri) }, |
92
|
|
|
|
|
|
|
$AtteanIRI ,=> q{ "URI"->new($_->as_string) }, |
93
|
|
|
|
|
|
|
Iri ,=> q{ "URI"->new($_->as_string) }, |
94
|
|
|
|
|
|
|
], |
95
|
|
|
|
|
|
|
}); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; # returns true |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=pod |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=encoding utf-8 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 NAME |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Types::URI - type constraints and coercions for URIs |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SYNOPSIS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
package FroobleDocument; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
use Moose; |
114
|
|
|
|
|
|
|
use Types::URI -all; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
has source => ( |
117
|
|
|
|
|
|
|
is => 'ro', |
118
|
|
|
|
|
|
|
isa => Uri, |
119
|
|
|
|
|
|
|
coerce => 1, |
120
|
|
|
|
|
|
|
); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 DESCRIPTION |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L<Types::URI> is a type constraint library suitable for use with |
125
|
|
|
|
|
|
|
L<Moo>/L<Moose> attributes, L<Kavorka> sub signatures, and so forth. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 Types |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This module provides some type constraints broadly compatible with |
130
|
|
|
|
|
|
|
those provided by L<MooseX::Types::URI>, plus a couple of extra type |
131
|
|
|
|
|
|
|
constraints. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=over |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item C<Uri> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
A class type for L<URI>/L<URI::WithBase>. Coercions from: |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item from C<Uuid> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Coerces to a URI in the C<< urn:uuid: >> schema. (See L<Types::UUID>.) |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item from C<Str> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Uses L<URI/new>. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item from C<Path> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Uses L<URI::file/new>. (See L<Types::Path::Tiny>.) |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item from C<ScalarRef> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Uses L<URI::data/new>. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item from C<HashRef> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Coerces using L<URI::FromHash>. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item from C<Iri> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Uses L<URI/new>. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item from L<RDF::Trine::Node::Resource>, L<RDF::Trine::Namespace>, L<XML::Namespace> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Uses L<URI/new>. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=back |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item C<FileUri> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
A subtype of C<Uri> covering L<URI::file>. Coercions from: |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item from C<Str> |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Uses L<URI::file/new>. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item from C<Path> |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Uses L<URI::file/new>. (See L<Types::Path::Tiny>.) |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item from C<HashRef> |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Coerces using L<URI::FromHash>. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item from C<Iri> |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Uses L<URI/new>. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item from L<RDF::Trine::Node::Resource>, L<RDF::Trine::Namespace>, L<XML::Namespace> |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Uses L<URI/new>. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=back |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item C<DataUri> |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
A subtype of C<Uri> covering L<URI::data>. Coercions from: |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=over |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item from C<Str> |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Uses L<URI::data/new>. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item from C<ScalarRef> |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Uses L<URI::data/new>. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item from C<HashRef> |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Coerces using L<URI::FromHash>. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=item from C<Iri> |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Uses L<URI/new>. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item from L<RDF::Trine::Node::Resource>, L<RDF::Trine::Namespace>, L<XML::Namespace> |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Uses L<URI/new>. |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=back |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item C<Iri> |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
A class type for L<IRI>. Coercions as per C<Uri> above, plus can coerce |
230
|
|
|
|
|
|
|
from C<Uri>. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=back |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 BUGS |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Please report any bugs to |
237
|
|
|
|
|
|
|
L<http://rt.cpan.org/Dist/Display.html?Queue=Types-URI>. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 SEE ALSO |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
L<MooseX::Types::URI>, |
242
|
|
|
|
|
|
|
L<Type::Tiny::Manual>, |
243
|
|
|
|
|
|
|
L<URI>, |
244
|
|
|
|
|
|
|
L<URI::file>, |
245
|
|
|
|
|
|
|
L<URI::data>, |
246
|
|
|
|
|
|
|
L<URI::FromHash>, |
247
|
|
|
|
|
|
|
L<RDF::Trine::Node::Resource>, |
248
|
|
|
|
|
|
|
L<IRI>. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
L<Types::UUID>, |
251
|
|
|
|
|
|
|
L<Types::Path::Tiny>, |
252
|
|
|
|
|
|
|
L<Types::Standard>. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head1 AUTHOR |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Toby Inkster. |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
263
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
268
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
269
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
270
|
|
|
|
|
|
|
|