line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
148017
|
use strict; |
|
2
|
|
|
|
|
21
|
|
|
2
|
|
|
|
|
64
|
|
2
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
136
|
|
3
|
|
|
|
|
|
|
package MooseX::Types::URI; # git description: v0.08-13-gb4d8e96 |
4
|
|
|
|
|
|
|
# ABSTRACT: URI related types and coercions for Moose |
5
|
|
|
|
|
|
|
# KEYWORDS: moose types constraints coercions uri path web |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.09'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
12
|
use Scalar::Util qw(blessed); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
106
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
614
|
use URI; |
|
2
|
|
|
|
|
15250
|
|
|
2
|
|
|
|
|
73
|
|
12
|
2
|
|
|
2
|
|
631
|
use URI::QueryParam; |
|
2
|
|
|
|
|
2168
|
|
|
2
|
|
|
|
|
66
|
|
13
|
2
|
|
|
2
|
|
578
|
use URI::WithBase; |
|
2
|
|
|
|
|
2343
|
|
|
2
|
|
|
|
|
73
|
|
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
530
|
use MooseX::Types::Moose qw{Str ScalarRef HashRef}; |
|
2
|
|
|
|
|
1098529
|
|
|
2
|
|
|
|
|
20
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
10029
|
use MooseX::Types 0.40 -declare => [qw(Uri _UriWithBase _Uri FileUri DataUri)]; |
|
2
|
|
|
|
|
58
|
|
|
2
|
|
|
|
|
14
|
|
18
|
2
|
|
|
2
|
|
12001
|
use if MooseX::Types->VERSION >= 0.42, 'namespace::autoclean'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
37
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $uri = Moose::Meta::TypeConstraint->new( |
21
|
|
|
|
|
|
|
name => Uri, |
22
|
|
|
|
|
|
|
parent => Moose::Meta::TypeConstraint::Union->new( |
23
|
|
|
|
|
|
|
name => join("|", _Uri, _UriWithBase), |
24
|
|
|
|
|
|
|
type_constraints => [ |
25
|
|
|
|
|
|
|
class_type( _Uri, { class => "URI" } ), |
26
|
|
|
|
|
|
|
class_type( _UriWithBase, { class => "URI::WithBase" } ), |
27
|
|
|
|
|
|
|
], |
28
|
|
|
|
|
|
|
), |
29
|
|
|
|
|
|
|
($Moose::VERSION >= 2.0100 |
30
|
|
|
|
|
|
|
? (inline_as => sub { 'local $@; blessed('.$_[1].') && ( '.$_[1].'->isa("URI") || '.$_[1].'->isa("URI::WithBase") )' }) |
31
|
|
|
|
|
|
|
: (optimized => sub { local $@; blessed($_[0]) && ( $_[0]->isa("URI") || $_[0]->isa("URI::WithBase") ) }) |
32
|
|
|
|
|
|
|
), |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
register_type_constraint($uri); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
coerce( Uri, |
38
|
|
|
|
|
|
|
from Str , via { URI->new($_) }, |
39
|
|
|
|
|
|
|
eval { +require MooseX::Types::Path::Class; 1 } |
40
|
|
|
|
|
|
|
? ( |
41
|
|
|
|
|
|
|
from "Path::Class::File", via { require URI::file; URI::file::->new($_) }, |
42
|
|
|
|
|
|
|
from "Path::Class::Dir" , via { require URI::file; URI::file::->new($_) }, |
43
|
|
|
|
|
|
|
from MooseX::Types::Path::Class::File() , via { require URI::file; URI::file::->new($_) }, |
44
|
|
|
|
|
|
|
from MooseX::Types::Path::Class::Dir() , via { require URI::file; URI::file::->new($_) }, |
45
|
|
|
|
|
|
|
) : (), |
46
|
|
|
|
|
|
|
from ScalarRef , via { my $u = URI->new("data:"); $u->data($$_); $u }, |
47
|
|
|
|
|
|
|
from HashRef , via { require URI::FromHash; URI::FromHash::uri_object(%$_) }, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
class_type FileUri, { class => "URI::file", parent => $uri }; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
coerce( FileUri, |
53
|
|
|
|
|
|
|
from Str , via { require URI::file; URI::file::->new($_) }, |
54
|
|
|
|
|
|
|
eval { +require MooseX::Types::Path::Class; 1 } |
55
|
|
|
|
|
|
|
? ( |
56
|
|
|
|
|
|
|
from MooseX::Types::Path::Class::File() , via { require URI::file; URI::file::->new($_) }, |
57
|
|
|
|
|
|
|
from MooseX::Types::Path::Class::Dir() , via { require URI::file; URI::file::->new($_) }, |
58
|
|
|
|
|
|
|
from "Path::Class::File" , via { require URI::file; URI::file::->new($_) }, |
59
|
|
|
|
|
|
|
from "Path::Class::Dir" , via { require URI::file; URI::file::->new($_) }, |
60
|
|
|
|
|
|
|
) : (), |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
class_type DataUri, { class => "URI::data" }; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
coerce( DataUri, |
66
|
|
|
|
|
|
|
from Str , via { my $u = URI->new("data:"); $u->data($_); $u }, |
67
|
|
|
|
|
|
|
from ScalarRef , via { my $u = URI->new("data:"); $u->data($$_); $u }, |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=pod |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=encoding UTF-8 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 NAME |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
MooseX::Types::URI - URI related types and coercions for Moose |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 VERSION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
version 0.09 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SYNOPSIS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
use MooseX::Types::URI qw(Uri FileUri DataUri); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This package provides Moose types for fun with L<URI>s. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 TYPES |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
The types are with C<ucfirst> naming convention so that they don't mask the |
97
|
|
|
|
|
|
|
L<URI> class. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 C<Uri> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Either L<URI> or L<URI::WithBase> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Coerces from C<Str> via L<URI/new>. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Coerces from L<Path::Class::File> and L<Path::Class::Dir> via L<URI::file/new> (but only if |
106
|
|
|
|
|
|
|
L<MooseX::Types::Path::Class> is installed) |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Coerces from C<ScalarRef> via L<URI::data/new>. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Coerces from C<HashRef> using L<URI::FromHash>. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 C<DataUri> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
A URI whose scheme is C<data>. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Coerces from C<Str> and C<ScalarRef> via L<URI::data/new>. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 C<FileUri> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
A L<URI::file> class type. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Has coercions from C<Str> (and optionally L<Path::Class::File> and L<Path::Class::Dir>) via L<URI::file/new> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=for stopwords DWIMier ducktyping |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
It has slightly DWIMier types than the L<URI> classes have due to |
127
|
|
|
|
|
|
|
implementation details, so the types should be more forgiving when ducktyping |
128
|
|
|
|
|
|
|
will work anyway (e.g. L<URI::WithBase> does not inherit L<URI>). |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=for stopwords TODO |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 TODO |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Think about L<Path::Resource> integration of some sort |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 SUPPORT |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-URI> |
139
|
|
|
|
|
|
|
(or L<bug-MooseX-Types-URI@rt.cpan.org|mailto:bug-MooseX-Types-URI@rt.cpan.org>). |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
142
|
|
|
|
|
|
|
L<http://lists.perl.org/list/moose.html>. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
145
|
|
|
|
|
|
|
L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 AUTHOR |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=for stopwords Karen Etheridge Florian Ragwitz Olivier Mengué Daniel Pittman MORIYA Masaki (gardejo) Shawn M Moore |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=over 4 |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Olivier Mengué <dolmen@cpan.org> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Daniel Pittman <daniel@rimspace.net> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item * |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
MORIYA Masaki (gardejo) <moriya@ermitejo.com> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Shawn M Moore <sartak@gmail.com> |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=back |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This software is copyright (c) 2008 by יובל קוג'מן (Yuval Kogman). |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
188
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=cut |