| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mo::utils::IRI; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
141662
|
use base qw(Exporter); |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
502
|
|
|
4
|
3
|
|
|
3
|
|
37
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
151
|
|
|
5
|
3
|
|
|
3
|
|
20
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
189
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1663
|
use English; |
|
|
3
|
|
|
|
|
7018
|
|
|
|
3
|
|
|
|
|
20
|
|
|
8
|
3
|
|
|
3
|
|
3058
|
use Error::Pure qw(err); |
|
|
3
|
|
|
|
|
19251
|
|
|
|
3
|
|
|
|
|
74
|
|
|
9
|
3
|
|
|
3
|
|
236
|
use Readonly; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
161
|
|
|
10
|
3
|
|
|
3
|
|
1932
|
use IRI; |
|
|
3
|
|
|
|
|
966196
|
|
|
|
3
|
|
|
|
|
1558
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(check_iri); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = 0.02; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub check_iri { |
|
17
|
9
|
|
|
9
|
1
|
375651
|
my ($self, $key) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
9
|
100
|
|
|
|
43
|
if (! exists $self->{$key}) { |
|
20
|
1
|
|
|
|
|
4
|
return; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
8
|
|
|
|
|
57
|
my $value = $self->{$key}; |
|
24
|
8
|
|
|
|
|
19
|
my $iri = eval { |
|
25
|
8
|
|
|
|
|
275
|
IRI->new($value); |
|
26
|
|
|
|
|
|
|
}; |
|
27
|
8
|
100
|
|
|
|
20450
|
if ($EVAL_ERROR) { |
|
28
|
2
|
|
|
|
|
12
|
err "Parameter '".$key."' doesn't contain valid IRI.", |
|
29
|
|
|
|
|
|
|
'Value', $value, |
|
30
|
|
|
|
|
|
|
; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
6
|
100
|
33
|
|
|
306
|
if (! $iri->can('scheme') || ! $iri->can('host') || ! $iri->scheme || ! $iri->host) { |
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
33
|
1
|
|
|
|
|
308
|
err "Parameter '".$key."' doesn't contain valid IRI.", |
|
34
|
|
|
|
|
|
|
'Value', $value, |
|
35
|
|
|
|
|
|
|
; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
5
|
|
|
|
|
2566
|
return; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=pod |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=encoding utf8 |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 NAME |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Mo::utils::IRI - Mo utilities for IRI. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
use Mo::utils::IRI qw(check_iri); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
check_iri($self, $key); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Mo utilities for IRI checking of data objects. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SUBROUTINES |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 C<check_iri> |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
check_iri($self, $key); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Check parameter defined by C<$key> which is valid IRI. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Put error if check isn't ok. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Returns undef. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 ERRORS |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
check_iri(): |
|
78
|
|
|
|
|
|
|
Parameter '%s' doesn't contain valid IRI. |
|
79
|
|
|
|
|
|
|
Value: %s |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 EXAMPLE1 |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=for comment filename=check_iri_ok.pl |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
use strict; |
|
86
|
|
|
|
|
|
|
use warnings; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
use Mo::utils::IRI qw(check_iri); |
|
89
|
|
|
|
|
|
|
use Unicode::UTF8 qw(decode_utf8); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my $self = { |
|
92
|
|
|
|
|
|
|
'key' => decode_utf8('https://michal.josef.špaček'), |
|
93
|
|
|
|
|
|
|
}; |
|
94
|
|
|
|
|
|
|
check_iri($self, 'key'); |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# Print out. |
|
97
|
|
|
|
|
|
|
print "ok\n"; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Output: |
|
100
|
|
|
|
|
|
|
# ok |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 EXAMPLE2 |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=for comment filename=check_iri_fail.pl |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
use strict; |
|
107
|
|
|
|
|
|
|
use warnings; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
use Error::Pure; |
|
110
|
|
|
|
|
|
|
use Mo::utils::IRI qw(check_iri); |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
$Error::Pure::TYPE = 'Error'; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $self = { |
|
115
|
|
|
|
|
|
|
'key' => 'bad_iri', |
|
116
|
|
|
|
|
|
|
}; |
|
117
|
|
|
|
|
|
|
check_iri($self, 'key'); |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Print out. |
|
120
|
|
|
|
|
|
|
print "ok\n"; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# Output like: |
|
123
|
|
|
|
|
|
|
# #Error [..utils.pm:?] Parameter 'key' doesn't contain valid IRI. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L<Error::Pure>, |
|
128
|
|
|
|
|
|
|
L<Exporter>, |
|
129
|
|
|
|
|
|
|
L<Readonly>, |
|
130
|
|
|
|
|
|
|
L<IRI>. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item L<Mo> |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Micro Objects. Mo is less. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item L<Mo::utils::CSS> |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Mo CSS utilities. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item L<Mo::utils::Date> |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Mo date utilities. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item L<Mo::utils::Language> |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Mo language utilities. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item L<Mo::utils::Email> |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Mo utilities for email. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item L<Mo::utils::URI> |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Mo utilities for URI. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item L<Wikibase::Datatype::Utils> |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Wikibase datatype utilities. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=back |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Mo-utils-IRI> |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 AUTHOR |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
L<http://skim.cz> |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
© 2024-2025 Michal Josef Špaček |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
BSD 2-Clause License |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 VERSION |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
0.02 |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |