line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Message::Simple; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
81843
|
use strict; |
|
6
|
|
|
|
|
46
|
|
|
6
|
|
|
|
|
177
|
|
4
|
6
|
|
|
6
|
|
31
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
272
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
2654
|
use Mo qw(build default is); |
|
6
|
|
|
|
|
3102
|
|
|
6
|
|
|
|
|
41
|
|
7
|
6
|
|
|
6
|
|
16700
|
use Mo::utils qw(check_length check_required check_strings); |
|
6
|
|
|
|
|
91395
|
|
|
6
|
|
|
|
|
111
|
|
8
|
6
|
|
|
6
|
|
3367
|
use Mo::utils::Language qw(check_language); |
|
6
|
|
|
|
|
1296752
|
|
|
6
|
|
|
|
|
161
|
|
9
|
6
|
|
|
6
|
|
417
|
use Readonly; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
1034
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Readonly::Array our @TYPES => qw(info error); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 0.01; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has lang => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has text => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has type => ( |
24
|
|
|
|
|
|
|
default => 'info', |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub BUILD { |
29
|
7
|
|
|
7
|
0
|
2930
|
my $self = shift; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Check lang. |
32
|
7
|
|
|
|
|
50
|
check_language($self, 'lang'); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Check text. |
35
|
7
|
|
|
|
|
819
|
check_required($self, 'text'); |
36
|
7
|
|
|
|
|
72
|
check_length($self, 'text', 4096); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Check message type. |
39
|
7
|
|
|
|
|
133
|
check_strings($self, 'type', \@TYPES); |
40
|
|
|
|
|
|
|
|
41
|
7
|
|
|
|
|
194
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=pod |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=encoding utf8 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 NAME |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Data::Message::Simple - Data object for simple message. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SYNOPSIS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
use Data::Message::Simple; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $obj = Data::Message::Simple->new(%params); |
61
|
|
|
|
|
|
|
my $lang = $obj->lang; |
62
|
|
|
|
|
|
|
my $name = $obj->text; |
63
|
|
|
|
|
|
|
my $type = $obj->type; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 METHODS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 C<new> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $obj = Data::Message::Simple->new(%params); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Constructor. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=over 8 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item * C<lang> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Message language. |
78
|
|
|
|
|
|
|
It's optional. |
79
|
|
|
|
|
|
|
If defined, possible values are ISO 639-1 language codes. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Default value is undef. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * C<text> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Message text. |
86
|
|
|
|
|
|
|
Maximum length of text is 4096 characters. |
87
|
|
|
|
|
|
|
It's required. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item * C<type> |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Message type. |
92
|
|
|
|
|
|
|
Possible value are 'error' and 'info'. |
93
|
|
|
|
|
|
|
It's required. |
94
|
|
|
|
|
|
|
Default value is 'info'. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=back |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Returns instance of object. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 C<lang> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $lane = $obj->lang; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Get ISO 639-1 language code of text. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns string. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 C<text> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my $text = $obj->text; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Get message text. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Returns string. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 C<type> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $type = $obj->type; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Get message type. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns string. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 EXAMPLE |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=for comment filename=create_and_print_message.pl |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
use strict; |
129
|
|
|
|
|
|
|
use warnings; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
use Data::Message::Simple; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
my $obj = Data::Message::Simple->new( |
134
|
|
|
|
|
|
|
'lang' => 'en', |
135
|
|
|
|
|
|
|
'text' => 'This is text message.', |
136
|
|
|
|
|
|
|
); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# Print out. |
139
|
|
|
|
|
|
|
print 'Message type: '.$obj->type."\n"; |
140
|
|
|
|
|
|
|
print 'ISO 639-1 language code: '.$obj->lang."\n"; |
141
|
|
|
|
|
|
|
print 'Text: '.$obj->text."\n"; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# Output: |
144
|
|
|
|
|
|
|
# Message type: info |
145
|
|
|
|
|
|
|
# ISO 639-1 language code: en |
146
|
|
|
|
|
|
|
# Text: This is text message. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L<Mo>, |
151
|
|
|
|
|
|
|
L<Mo::utils>, |
152
|
|
|
|
|
|
|
L<Mo::utils::Language>, |
153
|
|
|
|
|
|
|
L<Readonly>. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 REPOSITORY |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Data-Message-Simple> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 AUTHOR |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L<http://skim.cz> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
© 2023 Michal Josef Špaček |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
BSD 2-Clause License |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 VERSION |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
0.01 |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |