line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MouseX::Types::URI; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
47861
|
use 5.008_001; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
93
|
|
4
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
70
|
|
5
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
109
|
|
|
2
|
|
|
|
|
80
|
|
6
|
2
|
|
|
2
|
|
13
|
use Scalar::Util (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
42
|
|
7
|
2
|
|
|
2
|
|
1357
|
use URI; |
|
2
|
|
|
|
|
9454
|
|
|
2
|
|
|
|
|
60
|
|
8
|
2
|
|
|
2
|
|
3787
|
use URI::file; |
|
2
|
|
|
|
|
26333
|
|
|
2
|
|
|
|
|
71
|
|
9
|
2
|
|
|
2
|
|
2683
|
use URI::data; |
|
2
|
|
|
|
|
6339
|
|
|
2
|
|
|
|
|
66
|
|
10
|
2
|
|
|
2
|
|
2114
|
use URI::WithBase; |
|
2
|
|
|
|
|
1195
|
|
|
2
|
|
|
|
|
50
|
|
11
|
2
|
|
|
2
|
|
1964
|
use URI::FromHash (); |
|
2
|
|
|
|
|
34740
|
|
|
2
|
|
|
|
|
47
|
|
12
|
2
|
|
|
2
|
|
1892
|
use Mouse::Util::TypeConstraints; |
|
2
|
|
|
|
|
50691
|
|
|
2
|
|
|
|
|
13
|
|
13
|
2
|
|
|
2
|
|
2331
|
use MouseX::Types -declare => [qw(Uri FileUri DataUri)]; # export types |
|
2
|
|
|
|
|
8201
|
|
|
2
|
|
|
|
|
22
|
|
14
|
2
|
|
|
2
|
|
2414
|
use MouseX::Types::Mouse qw(Str ScalarRef HashRef); |
|
2
|
|
|
|
|
718
|
|
|
2
|
|
|
|
|
15
|
|
15
|
2
|
|
|
2
|
|
6186
|
use MouseX::Types::Path::Class qw(File Dir); |
|
2
|
|
|
|
|
374389
|
|
|
2
|
|
|
|
|
23
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
type 'URI', # doesn't use class_type 'URI' |
20
|
|
|
|
|
|
|
where { Scalar::Util::blessed($_) and ($_->isa('URI') or $_->isa('URI::WithBase')) }; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
class_type 'URI::file'; |
23
|
|
|
|
|
|
|
class_type 'URI::data'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
subtype Uri, as 'URI'; |
26
|
|
|
|
|
|
|
subtype FileUri, as 'URI::file'; |
27
|
|
|
|
|
|
|
subtype DataUri, as 'URI::data'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
for my $type ( 'URI', Uri ) { |
30
|
|
|
|
|
|
|
coerce($type, |
31
|
|
|
|
|
|
|
from Str, via { URI->new($_) }, |
32
|
|
|
|
|
|
|
from ScalarRef, via { my $u = URI->new('data:'); $u->data($$_); $u }, |
33
|
|
|
|
|
|
|
from HashRef, via { URI::FromHash::uri(%$_) }, |
34
|
|
|
|
|
|
|
from File, via { URI::file->new($_) }, |
35
|
|
|
|
|
|
|
from Dir, via { URI::file->new($_) }, |
36
|
|
|
|
|
|
|
from 'Path::Class::Dir', via { URI::file->new($_) }, |
37
|
|
|
|
|
|
|
from 'Path::Class::File', via { URI::file->new($_) }, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
for my $type ( 'URI::file', FileUri ) { |
42
|
|
|
|
|
|
|
coerce($type, |
43
|
|
|
|
|
|
|
from Str, via { URI::file->new($_) }, |
44
|
|
|
|
|
|
|
from File, via { URI::file->new($_) }, |
45
|
|
|
|
|
|
|
from Dir, via { URI::file->new($_) }, |
46
|
|
|
|
|
|
|
from 'Path::Class::Dir', via { URI::file->new($_) }, |
47
|
|
|
|
|
|
|
from 'Path::Class::File', via { URI::file->new($_) }, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
for my $type ( 'URI::data', DataUri ) { |
52
|
|
|
|
|
|
|
coerce($type, |
53
|
|
|
|
|
|
|
from Str, via { |
54
|
|
|
|
|
|
|
/^data:/ ? URI->new($_) : do { my $u = URI->new('data:'); $u->data($_); $u } |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
from ScalarRef, via { |
57
|
|
|
|
|
|
|
$$_ =~ /^data:/ ? URI->new($$_) : do { my $u = URI->new('data:'); $u->data($$_); $u } |
58
|
|
|
|
|
|
|
}, |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 NAME |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
MouseX::Types::URI - A URI type library for Mouse |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SYNOPSIS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 CLASS TYPES |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
package MyApp; |
73
|
|
|
|
|
|
|
use Mouse; |
74
|
|
|
|
|
|
|
use MouseX::Types::URI; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
has 'uri' => ( |
77
|
|
|
|
|
|
|
is => 'rw', |
78
|
|
|
|
|
|
|
isa => 'URI', |
79
|
|
|
|
|
|
|
coerce => 1, |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
has 'data' => ( |
83
|
|
|
|
|
|
|
is => 'rw', |
84
|
|
|
|
|
|
|
isa => 'URI::data', |
85
|
|
|
|
|
|
|
coerce => 1, |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
has 'file' => ( |
89
|
|
|
|
|
|
|
is => 'rw', |
90
|
|
|
|
|
|
|
isa => 'URI::file', |
91
|
|
|
|
|
|
|
coerce => 1, |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 CUSTOM TYPES |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
package MyApp; |
97
|
|
|
|
|
|
|
use Mouse; |
98
|
|
|
|
|
|
|
use MouseX::Types::URI qw(Uri DataUri FileUri); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
has 'uri' => ( |
101
|
|
|
|
|
|
|
is => 'rw', |
102
|
|
|
|
|
|
|
isa => Uri, |
103
|
|
|
|
|
|
|
coerce => 1, |
104
|
|
|
|
|
|
|
); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
has 'data' => ( |
107
|
|
|
|
|
|
|
is => 'rw', |
108
|
|
|
|
|
|
|
isa => DataUri, |
109
|
|
|
|
|
|
|
coerce => 1, |
110
|
|
|
|
|
|
|
); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
has 'file' => ( |
113
|
|
|
|
|
|
|
is => 'rw', |
114
|
|
|
|
|
|
|
isa => FileUri, |
115
|
|
|
|
|
|
|
coerce => 1, |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 DESCRIPTION |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
MouseX::Types::URI creates common L types, |
121
|
|
|
|
|
|
|
coercions and option specifications useful for dealing |
122
|
|
|
|
|
|
|
with Ls as L attributes. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Coercions (see L) are made from |
125
|
|
|
|
|
|
|
C, C, C, |
126
|
|
|
|
|
|
|
L and L to |
127
|
|
|
|
|
|
|
L, L and L objects. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 TYPES |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 Uri |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=over 4 |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Either L or L. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Coerces from C via L. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Coerces from L and L via L. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Coerces from C via L. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Coerces from C using L. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=back |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 DataUri |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=over 4 |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
A URI whose scheme is C. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Coerces from C and C via L. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=back |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 FileUri |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=over 4 |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
A L class type. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Coerces from C, L and L via L |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=back |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 AUTHOR |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
NAKAGAWA Masaki Emasaki@cpan.orgE |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 THANKS TO |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Yuval Kogman, L |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 LICENSE |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
178
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 SEE ALSO |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L, L, |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
L, L, L, L, L, |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
L |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |