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