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