line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::PMP::TypeConstraints; |
2
|
3
|
|
|
3
|
|
21
|
use Moose; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
16
|
|
3
|
3
|
|
|
3
|
|
16216
|
use Moose::Util::TypeConstraints; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
20
|
|
4
|
3
|
|
|
3
|
|
5555
|
use Data::Dump qw( dump ); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1528
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.006'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# The Net::PMP::Type::* prefix is used for all our type constraints |
9
|
|
|
|
|
|
|
# to avoid stepping on anyone's toes |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# links |
12
|
|
|
|
|
|
|
my $coerce_link = sub { |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# defer till runtime to avoid circular dependency |
15
|
|
|
|
|
|
|
require Net::PMP::CollectionDoc::Link; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
if ( ref( $_[0] ) eq 'HASH' ) { |
18
|
|
|
|
|
|
|
return Net::PMP::CollectionDoc::Link->new( $_[0] ); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
elsif ( blessed $_[0] and $_[0]->isa('URI') ) { |
21
|
|
|
|
|
|
|
return Net::PMP::CollectionDoc::Link->new( href => $_[0] . "" ); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
elsif ( blessed $_[0] ) { |
24
|
|
|
|
|
|
|
return $_[0]; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
else { |
27
|
|
|
|
|
|
|
return Net::PMP::CollectionDoc::Link->new( href => $_[0] ); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
subtype 'Net::PMP::Type::Link' => |
31
|
|
|
|
|
|
|
as class_type('Net::PMP::CollectionDoc::Link') => message { |
32
|
|
|
|
|
|
|
'Value ' . dump($_) . ' is not a valid Net::PMP::CollectionDoc::Link'; |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
coerce 'Net::PMP::Type::Link' => from 'Any' => via { $coerce_link->($_) }; |
35
|
|
|
|
|
|
|
subtype 'Net::PMP::Type::Links' => as 'ArrayRef[Net::PMP::Type::Link]' => |
36
|
|
|
|
|
|
|
message { |
37
|
|
|
|
|
|
|
'Value ' |
38
|
|
|
|
|
|
|
. dump($_) |
39
|
|
|
|
|
|
|
. ' is not a valid ArrayRef of type Net::PMP::Type::Link'; |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
coerce 'Net::PMP::Type::Links' => from 'ArrayRef' => via { |
42
|
|
|
|
|
|
|
[ map { $coerce_link->($_) } @$_ ]; |
43
|
|
|
|
|
|
|
} => from 'HashRef' => via { [ $coerce_link->($_) ] } => from 'Any' => |
44
|
|
|
|
|
|
|
via { [ $coerce_link->($_) ] }; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# permission links (special link case) |
47
|
|
|
|
|
|
|
my $coerce_permission = sub { |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# defer till runtime to avoid circular dependency |
50
|
|
|
|
|
|
|
require Net::PMP::CollectionDoc::Permission; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
if ( ref( $_[0] ) eq 'HASH' ) { |
53
|
|
|
|
|
|
|
return Net::PMP::CollectionDoc::Permission->new( $_[0] ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
elsif ( blessed $_[0] ) { |
56
|
|
|
|
|
|
|
return $_[0]; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
|
|
|
|
|
|
return Net::PMP::CollectionDoc::Permission->new( href => $_[0] ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
subtype 'Net::PMP::Type::Permission' => |
63
|
|
|
|
|
|
|
as class_type('Net::PMP::CollectionDoc::Permission'); |
64
|
|
|
|
|
|
|
coerce 'Net::PMP::Type::Permission' => from 'Any' => |
65
|
|
|
|
|
|
|
via { $coerce_permission->($_) }; |
66
|
|
|
|
|
|
|
subtype 'Net::PMP::Type::Permissions' => as |
67
|
|
|
|
|
|
|
'ArrayRef[Net::PMP::Type::Permission]'; |
68
|
|
|
|
|
|
|
coerce 'Net::PMP::Type::Permissions' => from 'ArrayRef' => via { |
69
|
|
|
|
|
|
|
[ map { $coerce_permission->($_) } @$_ ]; |
70
|
|
|
|
|
|
|
} => from 'HashRef' => via { [ $coerce_permission->($_) ] } => from 'Any' => |
71
|
|
|
|
|
|
|
via { [ $coerce_permission->($_) ] }; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# URIs |
74
|
3
|
|
|
3
|
|
1001
|
use Data::Validate::URI qw(is_uri); |
|
3
|
|
|
|
|
102571
|
|
|
3
|
|
|
|
|
577
|
|
75
|
|
|
|
|
|
|
subtype 'Net::PMP::Type::Href' => as 'Str' => where { |
76
|
|
|
|
|
|
|
is_uri($_); |
77
|
|
|
|
|
|
|
} => message { "Value " . dump($_) . " is not a valid href." }; |
78
|
|
|
|
|
|
|
coerce 'Net::PMP::Type::Href' => from 'Object' => via {"$_"}; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# GUIDs |
81
|
|
|
|
|
|
|
subtype 'Net::PMP::Type::GUID' => as 'Str' => where { |
82
|
|
|
|
|
|
|
m/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/; |
83
|
|
|
|
|
|
|
} => message {"Value ($_) does not look like a valid guid."}; |
84
|
|
|
|
|
|
|
|
85
|
3
|
|
|
3
|
|
25
|
no Moose::Util::TypeConstraints; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
28
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 NAME |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Net::PMP::CollectionDoc::Link - link from a Net::PMP::CollectionDoc::Links object |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 SYNOPSIS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
package My::Class; |
100
|
|
|
|
|
|
|
use Moose; |
101
|
|
|
|
|
|
|
use Net::PMP::Profile::TypeConstraints; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# provide validation checking |
104
|
|
|
|
|
|
|
has 'uri' => (isa => 'Net::PMP::Type::Href'); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 DESCRIPTION |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Net::PMP::Profile::TypeConstraints defines validation constraints for Net::PMP classes. |
111
|
|
|
|
|
|
|
This is a utility class defining types with L<Moose::Util::TypeConstraints> |
112
|
|
|
|
|
|
|
in the C<Net::PMP::Type> namespace. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 AUTHOR |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Peter Karman, C<< <karman at cpan.org> >> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 BUGS |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-net-pmp at rt.cpan.org>, or through |
121
|
|
|
|
|
|
|
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-PMP-Profile>. I will be notified, and then you'll |
122
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 SUPPORT |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
perldoc Net::PMP::CollectionDoc::Link |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
You can also look for information at: |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over 4 |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-PMP> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Net-PMP> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item * CPAN Ratings |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Net-PMP> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * Search CPAN |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Net-PMP/> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=back |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
American Public Media and the Public Media Platform sponsored the development of this module. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Copyright 2013 American Public Media Group |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
See the LICENSE file that accompanies this module. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
166
|
|
|
|
|
|
|
|