| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Icon; |
|
2
|
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
201376
|
use strict; |
|
|
8
|
|
|
|
|
16
|
|
|
|
8
|
|
|
|
|
388
|
|
|
4
|
8
|
|
|
8
|
|
51
|
use warnings; |
|
|
8
|
|
|
|
|
13
|
|
|
|
8
|
|
|
|
|
540
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
4602
|
use Error::Pure qw(err); |
|
|
8
|
|
|
|
|
122125
|
|
|
|
8
|
|
|
|
|
214
|
|
|
7
|
8
|
|
|
8
|
|
5312
|
use Mo qw(build is); |
|
|
8
|
|
|
|
|
5706
|
|
|
|
8
|
|
|
|
|
53
|
|
|
8
|
8
|
|
|
8
|
|
22677
|
use Mo::utils 0.05 qw(check_length); |
|
|
8
|
|
|
|
|
29093
|
|
|
|
8
|
|
|
|
|
1552
|
|
|
9
|
8
|
|
|
8
|
|
6550
|
use Mo::utils::CSS 0.03 qw(check_css_color); |
|
|
8
|
|
|
|
|
94991
|
|
|
|
8
|
|
|
|
|
181
|
|
|
10
|
8
|
|
|
8
|
|
4774
|
use Mo::utils::URI 0.02 qw(check_location); |
|
|
8
|
|
|
|
|
677154
|
|
|
|
8
|
|
|
|
|
278
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = 0.02; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has alt => ( |
|
15
|
|
|
|
|
|
|
is => 'ro', |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has bg_color => ( |
|
19
|
|
|
|
|
|
|
is => 'ro', |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has char => ( |
|
23
|
|
|
|
|
|
|
is => 'ro', |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has color => ( |
|
27
|
|
|
|
|
|
|
is => 'ro', |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has url => ( |
|
31
|
|
|
|
|
|
|
is => 'ro', |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub BUILD { |
|
35
|
18
|
|
|
18
|
0
|
2151987
|
my $self = shift; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Check alt. |
|
38
|
18
|
|
|
|
|
105
|
check_length($self, 'alt', 100); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Check bg_color. |
|
41
|
18
|
|
|
|
|
383
|
check_css_color($self, 'bg_color'); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Check char. |
|
44
|
18
|
|
|
|
|
2170
|
check_length($self, 'char', 1); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Check color. |
|
47
|
18
|
|
|
|
|
221
|
check_css_color($self, 'color'); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Check url. |
|
50
|
18
|
|
|
|
|
2728
|
check_location($self, 'url'); |
|
51
|
|
|
|
|
|
|
# TODO Check image |
|
52
|
|
|
|
|
|
|
|
|
53
|
17
|
100
|
100
|
|
|
42579
|
if (defined $self->{'char'} && defined $self->{'url'}) { |
|
54
|
1
|
|
|
|
|
37
|
err "Parameter 'url' is in conflict with parameter 'char'."; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
16
|
100
|
100
|
|
|
79
|
if (defined $self->{'char'} && defined $self->{'alt'}) { |
|
58
|
1
|
|
|
|
|
10
|
err "Parameter 'char' don't need parameter 'alt'."; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
15
|
100
|
|
|
|
54
|
if (defined $self->{'url'}) { |
|
62
|
5
|
100
|
|
|
|
19
|
if (defined $self->{'color'}) { |
|
63
|
1
|
|
|
|
|
6
|
err "Parameter 'url' don't need parameter 'color'."; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
4
|
100
|
|
|
|
16
|
if (defined $self->{'bg_color'}) { |
|
66
|
1
|
|
|
|
|
38
|
err "Parameter 'url' don't need parameter 'bg_color'."; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
13
|
|
|
|
|
40
|
return; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=pod |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=encoding utf8 |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 NAME |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Data::Icon - Data object for icon. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Data object for description of icon. It could be defined as URL with alternate |
|
88
|
|
|
|
|
|
|
text or as UTF-8 character with colors. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
use Data::Icon; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $obj = Data::Icon->new(%params); |
|
95
|
|
|
|
|
|
|
my $alt = $obj->alt; |
|
96
|
|
|
|
|
|
|
my $bg_color = $obj->bg_color; |
|
97
|
|
|
|
|
|
|
my $char = $obj->char; |
|
98
|
|
|
|
|
|
|
my $color = $obj->color; |
|
99
|
|
|
|
|
|
|
my $url = $obj->url; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 METHODS |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 C<new> |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $obj = Data::Icon->new(%params); |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Constructor. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=over 8 |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * C<alt> |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Alternate text for image icon. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
It's optional. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * C<bg_color> |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Background color for UTF-8 character. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
It's optional. |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * C<char> |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Icon character. Could be UTF-8 character. Only one character. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
It's optional. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * C<color> |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Character color. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
It's optional. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * C<url> |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Icon URL. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
It's optional. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Returns instance of object. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 C<alt> |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
my $alt = $obj->alt; |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Get alternate text for image icon. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Returns string. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 C<bg_color> |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
my $bg_color = $obj->bg_color; |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Get background color for UTF-8 character. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Returns string. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 C<char> |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
my $char = $obj->char; |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Get icon character. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Returns string. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 C<color> |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
my $color = $obj->color; |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Get character color. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Returns CSS color string. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 C<url> |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
my $url = $obj->url; |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Get icon URL. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Returns string. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 ERRORS |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
new(): |
|
188
|
|
|
|
|
|
|
Parameter 'char' don't need parameter 'alt'. |
|
189
|
|
|
|
|
|
|
Parameter 'url' don't need parameter 'bg_color'. |
|
190
|
|
|
|
|
|
|
Parameter 'url' don't need parameter 'color'. |
|
191
|
|
|
|
|
|
|
Parameter 'url' is in conflict with parameter 'char'. |
|
192
|
|
|
|
|
|
|
From Mo::utils: |
|
193
|
|
|
|
|
|
|
Parameter 'alt' has length greater than '100'. |
|
194
|
|
|
|
|
|
|
Value: %s |
|
195
|
|
|
|
|
|
|
Parameter 'char' has length greater than '1'. |
|
196
|
|
|
|
|
|
|
Value: %s |
|
197
|
|
|
|
|
|
|
From Mo::utils::CSS::check_css_color(): |
|
198
|
|
|
|
|
|
|
Parameter '%s' has bad color name. |
|
199
|
|
|
|
|
|
|
Value: %s |
|
200
|
|
|
|
|
|
|
Parameter '%s' has bad rgb color (bad hex number). |
|
201
|
|
|
|
|
|
|
Value: %s |
|
202
|
|
|
|
|
|
|
Parameter '%s' has bad rgb color (bad length). |
|
203
|
|
|
|
|
|
|
Value: %s |
|
204
|
|
|
|
|
|
|
From Mo::utils::URI::check_location(): |
|
205
|
|
|
|
|
|
|
Parameter 'url' doesn't contain valid location. |
|
206
|
|
|
|
|
|
|
Value: %s |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 EXAMPLE1 |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=for comment filename=create_image_icon_and_print.pl |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
use strict; |
|
213
|
|
|
|
|
|
|
use warnings; |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
use Data::Icon; |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
my $obj = Data::Icon->new( |
|
218
|
|
|
|
|
|
|
'alt' => 'Foo icon', |
|
219
|
|
|
|
|
|
|
'url' => 'https://example.com/foo.png', |
|
220
|
|
|
|
|
|
|
); |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
# Print out. |
|
223
|
|
|
|
|
|
|
print "Alternate text: ".$obj->alt."\n"; |
|
224
|
|
|
|
|
|
|
print "Icon URL: ".$obj->url."\n"; |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
# Output: |
|
227
|
|
|
|
|
|
|
# Alternate text: Foo icon |
|
228
|
|
|
|
|
|
|
# Icon URL: https://example.com/foo.png |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head1 EXAMPLE2 |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=for comment filename=create_char_icon_and_print.pl |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
use strict; |
|
235
|
|
|
|
|
|
|
use warnings; |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
use Data::Icon; |
|
238
|
|
|
|
|
|
|
use Unicode::UTF8 qw(decode_utf8 encode_utf8); |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
my $obj = Data::Icon->new( |
|
241
|
|
|
|
|
|
|
'bg_color' => 'grey', |
|
242
|
|
|
|
|
|
|
'char' => decode_utf8('†'), |
|
243
|
|
|
|
|
|
|
'color' => 'red', |
|
244
|
|
|
|
|
|
|
); |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
# Print out. |
|
247
|
|
|
|
|
|
|
print "Character: ".encode_utf8($obj->char)."\n"; |
|
248
|
|
|
|
|
|
|
print "CSS color: ".$obj->color."\n"; |
|
249
|
|
|
|
|
|
|
print "CSS background color: ".$obj->bg_color."\n"; |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
# Output: |
|
252
|
|
|
|
|
|
|
# Character: † |
|
253
|
|
|
|
|
|
|
# CSS color: red |
|
254
|
|
|
|
|
|
|
# CSS background color: grey |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
L<Error::Pure>, |
|
259
|
|
|
|
|
|
|
L<Mo>, |
|
260
|
|
|
|
|
|
|
L<Mo::utils>, |
|
261
|
|
|
|
|
|
|
L<Mo::utils::CSS>, |
|
262
|
|
|
|
|
|
|
L<Mo::utils::URI>. |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Data-Icon> |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 AUTHOR |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
L<http://skim.cz> |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
© 2025 Michal Josef Špaček |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
BSD 2-Clause License |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=head1 VERSION |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
0.02 |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=cut |