| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Message::Board; |
|
2
|
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
174114
|
use strict; |
|
|
16
|
|
|
|
|
28
|
|
|
|
16
|
|
|
|
|
573
|
|
|
4
|
16
|
|
|
16
|
|
92
|
use warnings; |
|
|
16
|
|
|
|
|
56
|
|
|
|
16
|
|
|
|
|
981
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
16
|
|
|
16
|
|
7216
|
use Mo qw(build default is); |
|
|
16
|
|
|
|
|
9705
|
|
|
|
16
|
|
|
|
|
91
|
|
|
7
|
16
|
|
|
16
|
|
47329
|
use Mo::utils 0.28 qw(check_isa check_length check_required); |
|
|
16
|
|
|
|
|
264971
|
|
|
|
16
|
|
|
|
|
469
|
|
|
8
|
16
|
|
|
16
|
|
14045
|
use Mo::utils::Array qw(check_array_object); |
|
|
16
|
|
|
|
|
56057
|
|
|
|
16
|
|
|
|
|
371
|
|
|
9
|
16
|
|
|
16
|
|
11508
|
use Mo::utils::Number qw(check_positive_natural); |
|
|
16
|
|
|
|
|
38824
|
|
|
|
16
|
|
|
|
|
369
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.06; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has author => ( |
|
14
|
|
|
|
|
|
|
is => 'ro', |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has comments => ( |
|
18
|
|
|
|
|
|
|
default => [], |
|
19
|
|
|
|
|
|
|
is => 'ro', |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has date => ( |
|
23
|
|
|
|
|
|
|
is => 'ro', |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has id => ( |
|
27
|
|
|
|
|
|
|
is => 'ro', |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has message => ( |
|
31
|
|
|
|
|
|
|
is => 'ro', |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub BUILD { |
|
35
|
25
|
|
|
25
|
0
|
8190351
|
my $self = shift; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Check author. |
|
38
|
25
|
|
|
|
|
142
|
check_required($self, 'author'); |
|
39
|
24
|
|
|
|
|
280
|
check_isa($self, 'author', 'Data::Person'); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Check comments. |
|
42
|
22
|
|
|
|
|
578
|
check_array_object($self, 'comments', 'Data::Message::Board::Comment'); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Check date. |
|
45
|
20
|
|
|
|
|
503
|
check_required($self, 'date'); |
|
46
|
19
|
|
|
|
|
157
|
check_isa($self, 'date', 'DateTime'); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Check id. |
|
49
|
17
|
|
|
|
|
376
|
check_positive_natural($self, 'id'); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Check message. |
|
52
|
16
|
|
|
|
|
307
|
check_required($self, 'message'); |
|
53
|
15
|
|
|
|
|
122
|
check_length($self, 'message', 4096); |
|
54
|
|
|
|
|
|
|
|
|
55
|
14
|
|
|
|
|
183
|
return; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=pod |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=encoding utf8 |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Data::Message::Board - Data object for Message board. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
use Data::Message::Board; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $obj = Data::Message::Board->new(%params); |
|
75
|
|
|
|
|
|
|
my $author = $obj->author; |
|
76
|
|
|
|
|
|
|
my $comments_ar = $obj->comments; |
|
77
|
|
|
|
|
|
|
my $date = $obj->date; |
|
78
|
|
|
|
|
|
|
my $id = $obj->id; |
|
79
|
|
|
|
|
|
|
my $message = $obj->message; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 METHODS |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 C<new> |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $obj = Data::Message::Board->new(%params); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Constructor. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over 8 |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item * C<author> |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Author object which is L<Data::Person> instance. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
It's required. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * C<comments> |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Message board comments which are L<Data::Mesaage::Board::Comment> instances. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Default value is []. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item * C<date> |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Date of comment which is L<DateTime> instance. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
It's required. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * C<id> |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Id. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Default value is undef. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * C<message> |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Main comment message. Max length of message is 4096 character. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
It's required. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=back |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Returns instance of object. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 C<author> |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
my $author = $obj->author; |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Get author instance. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Returns L<Data::Person> instance. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 C<comments> |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
my $comments_ar = $obj->comments; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Get message board comments. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Returns reference to array with L<Data::Message::Board::Comment> instances. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 C<date> |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
my $date = $obj->date; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Get datetime of comment. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Returns L<DateTime> instance. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 C<id> |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
my $id = $obj->id; |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Get comment id. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Returns natural number. |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 C<> |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
my $message = $obj->message; |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Get comment message. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Returns string. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 ERRORS |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
new(): |
|
168
|
|
|
|
|
|
|
From Mo::utils::check_isa(): |
|
169
|
|
|
|
|
|
|
Parameter 'author' must be a 'Data::Person' object. |
|
170
|
|
|
|
|
|
|
Value: %s |
|
171
|
|
|
|
|
|
|
Reference: %s |
|
172
|
|
|
|
|
|
|
Parameter 'date' must be a 'DateTime' object. |
|
173
|
|
|
|
|
|
|
Value: %s |
|
174
|
|
|
|
|
|
|
Reference: %s |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
From Mo::utils::check_length(): |
|
177
|
|
|
|
|
|
|
Parameter 'message' has length greater than '4096'. |
|
178
|
|
|
|
|
|
|
Value: %s |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
From Mo::utils::check_required(): |
|
181
|
|
|
|
|
|
|
Parameter 'author' is required. |
|
182
|
|
|
|
|
|
|
Parameter 'date' is required. |
|
183
|
|
|
|
|
|
|
Parameter 'message' is required. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
From Mo::utils::Array::check_array_object(): |
|
186
|
|
|
|
|
|
|
Parameter 'comments' must be a array. |
|
187
|
|
|
|
|
|
|
Value: %s |
|
188
|
|
|
|
|
|
|
Reference: %s |
|
189
|
|
|
|
|
|
|
Parameter 'comments' with array must contain 'Data::Message::Board::Comment' objects. |
|
190
|
|
|
|
|
|
|
Value: %s |
|
191
|
|
|
|
|
|
|
Reference: %s |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
From Mo::utils::Number::check_positive_natural(): |
|
194
|
|
|
|
|
|
|
Parameter 'id' must be a positive natural number. |
|
195
|
|
|
|
|
|
|
Value: %s |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 EXAMPLE |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=for comment filename=message_board.pl |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
use strict; |
|
203
|
|
|
|
|
|
|
use warnings; |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
use Data::Message::Board; |
|
206
|
|
|
|
|
|
|
use Data::Message::Board::Comment; |
|
207
|
|
|
|
|
|
|
use Data::Person; |
|
208
|
|
|
|
|
|
|
use DateTime; |
|
209
|
|
|
|
|
|
|
use Unicode::UTF8 qw(decode_utf8 encode_utf8); |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
my $dt = DateTime->now; |
|
212
|
|
|
|
|
|
|
my $dt_comment1 = $dt->clone->add('minutes' => 5); |
|
213
|
|
|
|
|
|
|
my $dt_comment2 = $dt_comment1->clone->add('seconds' => 34); |
|
214
|
|
|
|
|
|
|
my $obj = Data::Message::Board->new( |
|
215
|
|
|
|
|
|
|
'author' => Data::Person->new( |
|
216
|
|
|
|
|
|
|
'email' => 'skim@cpan.org', |
|
217
|
|
|
|
|
|
|
'name' => decode_utf8('Michal Josef Špaček'), |
|
218
|
|
|
|
|
|
|
), |
|
219
|
|
|
|
|
|
|
'comments' => [ |
|
220
|
|
|
|
|
|
|
Data::Message::Board::Comment->new( |
|
221
|
|
|
|
|
|
|
'author' => Data::Person->new( |
|
222
|
|
|
|
|
|
|
'email' => 'bar@example.com', |
|
223
|
|
|
|
|
|
|
'name' => decode_utf8('St. John'), |
|
224
|
|
|
|
|
|
|
), |
|
225
|
|
|
|
|
|
|
'date' => $dt_comment1, |
|
226
|
|
|
|
|
|
|
'id' => 7, |
|
227
|
|
|
|
|
|
|
'message' => 'I am fine.', |
|
228
|
|
|
|
|
|
|
), |
|
229
|
|
|
|
|
|
|
Data::Message::Board::Comment->new( |
|
230
|
|
|
|
|
|
|
'author' => Data::Person->new( |
|
231
|
|
|
|
|
|
|
'email' => 'foo@example.com', |
|
232
|
|
|
|
|
|
|
'name' => decode_utf8('John Wick'), |
|
233
|
|
|
|
|
|
|
), |
|
234
|
|
|
|
|
|
|
'date' => $dt_comment2, |
|
235
|
|
|
|
|
|
|
'id' => 6, |
|
236
|
|
|
|
|
|
|
'message' => 'Not bad.', |
|
237
|
|
|
|
|
|
|
), |
|
238
|
|
|
|
|
|
|
], |
|
239
|
|
|
|
|
|
|
'date' => $dt, |
|
240
|
|
|
|
|
|
|
'id' => 1, |
|
241
|
|
|
|
|
|
|
'message' => 'How are you?', |
|
242
|
|
|
|
|
|
|
); |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
# Print out. |
|
245
|
|
|
|
|
|
|
print 'Author name: '.encode_utf8($obj->author->name)."\n"; |
|
246
|
|
|
|
|
|
|
print 'Author email: '.$obj->author->email."\n"; |
|
247
|
|
|
|
|
|
|
print 'Date: '.$obj->date."\n"; |
|
248
|
|
|
|
|
|
|
print 'Id: '.$obj->id."\n"; |
|
249
|
|
|
|
|
|
|
print 'Message: '.$obj->message."\n"; |
|
250
|
|
|
|
|
|
|
print "Comments:\n"; |
|
251
|
|
|
|
|
|
|
map { |
|
252
|
|
|
|
|
|
|
print "\tAuthor name: ".$_->author->name."\n"; |
|
253
|
|
|
|
|
|
|
print "\tDate: ".$_->date."\n"; |
|
254
|
|
|
|
|
|
|
print "\tId: ".$_->id."\n"; |
|
255
|
|
|
|
|
|
|
print "\tComment: ".$_->message."\n\n"; |
|
256
|
|
|
|
|
|
|
} @{$obj->comments}; |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
# Output: |
|
259
|
|
|
|
|
|
|
# Author name: Michal Josef Špaček |
|
260
|
|
|
|
|
|
|
# Author email: skim@cpan.org |
|
261
|
|
|
|
|
|
|
# Date: 2024-05-27T18:10:55 |
|
262
|
|
|
|
|
|
|
# Id: 1 |
|
263
|
|
|
|
|
|
|
# Message: How are you? |
|
264
|
|
|
|
|
|
|
# Comments: |
|
265
|
|
|
|
|
|
|
# Author name: St. John |
|
266
|
|
|
|
|
|
|
# Date: 2024-05-27T18:15:55 |
|
267
|
|
|
|
|
|
|
# Id: 7 |
|
268
|
|
|
|
|
|
|
# Comment: I am fine. |
|
269
|
|
|
|
|
|
|
# |
|
270
|
|
|
|
|
|
|
# Author name: John Wick |
|
271
|
|
|
|
|
|
|
# Date: 2024-05-27T18:16:29 |
|
272
|
|
|
|
|
|
|
# Id: 6 |
|
273
|
|
|
|
|
|
|
# Comment: Not bad. |
|
274
|
|
|
|
|
|
|
# |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
L<Mo>, |
|
279
|
|
|
|
|
|
|
L<Mo::utils>, |
|
280
|
|
|
|
|
|
|
L<Mo::utils::Array>, |
|
281
|
|
|
|
|
|
|
L<Mo::utils::Number>. |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=over |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=item L<Tags::HTML::Message::Board> |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
Tags helper for message board. |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=item L<Tags::HTML::Message::Board::Blank> |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
Tags helper for message board blank page. |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=back |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Data-Message-Board> |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=head1 AUTHOR |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
L<http://skim.cz> |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
© 2024-2025 Michal Josef Špaček |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
BSD 2-Clause License |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=head1 VERSION |
|
314
|
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
0.06 |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=cut |