line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Toolforge::MixNMatch::Object::Catalog; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
205449
|
use strict; |
|
3
|
|
|
|
|
22
|
|
|
3
|
|
|
|
|
70
|
|
4
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
69
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
1189
|
use Mo qw(build default is); |
|
3
|
|
|
|
|
1263
|
|
|
3
|
|
|
|
|
14
|
|
7
|
3
|
|
|
3
|
|
7224
|
use Mo::utils qw(check_array_object check_required); |
|
3
|
|
|
|
|
24189
|
|
|
3
|
|
|
|
|
46
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.03; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has count => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has type => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has year_months => ( |
20
|
|
|
|
|
|
|
default => [], |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has users => ( |
25
|
|
|
|
|
|
|
default => [], |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub BUILD { |
30
|
3
|
|
|
3
|
0
|
16013
|
my $self = shift; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Check require. |
33
|
3
|
|
|
|
|
11
|
check_required($self, 'count'); |
34
|
2
|
|
|
|
|
19
|
check_required($self, 'type'); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Check year month. |
37
|
1
|
|
|
|
|
8
|
check_array_object($self, 'year_months', 'Toolforge::MixNMatch::Object::YearMonth', |
38
|
|
|
|
|
|
|
'Year/month'); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Check users. |
41
|
1
|
|
|
|
|
8
|
check_array_object($self, 'users', 'Toolforge::MixNMatch::Object::User', |
42
|
|
|
|
|
|
|
'User'); |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
5
|
return; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=pod |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=encoding utf8 |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Toolforge::MixNMatch::Object::Catalog - Mix'n'match catalog datatype. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 SYNOPSIS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
use Toolforge::MixNMatch::Object::Catalog; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $obj = Toolforge::MixNMatch::Object::Catalog->new(%params); |
64
|
|
|
|
|
|
|
my $count = $obj->count; |
65
|
|
|
|
|
|
|
my $type = $obj->type; |
66
|
|
|
|
|
|
|
my $year_months = $obj->year_months; |
67
|
|
|
|
|
|
|
my $users = $obj->users; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 DESCRIPTION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This datatype is base class for Mix'n'match catalog. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 METHODS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 C<new> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $obj = Toolforge::MixNMatch::Object::Catalog->new(%params); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Constructor. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns instance of object. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=over 8 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * C<count> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Count number of records in catalog. |
88
|
|
|
|
|
|
|
Parameter is required. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * C<type> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Catalog type in sense of Wikidata instance. |
93
|
|
|
|
|
|
|
Example is 'Q5' for human. |
94
|
|
|
|
|
|
|
Parameter is required. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item * C<year_months> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Year/months statistics. |
99
|
|
|
|
|
|
|
Reference to array with Toolforge::MixNMatch::Object::YearMonth instances. |
100
|
|
|
|
|
|
|
Default value is []. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item * C<users> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Users statistics. |
105
|
|
|
|
|
|
|
Reference to array with Toolforge::MixNMatch::Object::User instances. |
106
|
|
|
|
|
|
|
Default value is []. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=back |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 C<count> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my $count = $obj->count; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Get count. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Returns number. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 C<type> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my $type = $obj->type; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Get type. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Returns string. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 C<year_months> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
my $year_months = $obj->year_months; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Get year/months statistics. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Returns reference to array with Toolforge::MixNMatch::Object::YearMonth |
133
|
|
|
|
|
|
|
instances. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 C<users> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $users = $obj->users; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Get users statistics. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Returns reference to array with Toolforge::MixNMatch::Object::User |
142
|
|
|
|
|
|
|
instances. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 ERRORS |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
new(): |
147
|
|
|
|
|
|
|
From Mo::utils::check_required(): |
148
|
|
|
|
|
|
|
Parameter 'count' is required. |
149
|
|
|
|
|
|
|
Parameter 'type' is required. |
150
|
|
|
|
|
|
|
From Mo::utils::check_array_object(): |
151
|
|
|
|
|
|
|
Parameter 'users' must be a array. |
152
|
|
|
|
|
|
|
Parameter 'year_months' must be a array. |
153
|
|
|
|
|
|
|
User isn't 'Toolforge::MixNMatch::Object::Catalog::User' object. |
154
|
|
|
|
|
|
|
Year/month isn't 'Toolforge::MixNMatch::Object::Catalog::YearMonth' object. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 EXAMPLE |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
use strict; |
159
|
|
|
|
|
|
|
use warnings; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
use Toolforge::MixNMatch::Object::Catalog; |
162
|
|
|
|
|
|
|
use Toolforge::MixNMatch::Object::User; |
163
|
|
|
|
|
|
|
use Toolforge::MixNMatch::Object::YearMonth; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# Object. |
166
|
|
|
|
|
|
|
my $obj = Toolforge::MixNMatch::Object::Catalog->new( |
167
|
|
|
|
|
|
|
'count' => 10, |
168
|
|
|
|
|
|
|
'type' => 'Q5', |
169
|
|
|
|
|
|
|
'users' => [ |
170
|
|
|
|
|
|
|
Toolforge::MixNMatch::Object::User->new( |
171
|
|
|
|
|
|
|
'count' => 6, |
172
|
|
|
|
|
|
|
'uid' => 1, |
173
|
|
|
|
|
|
|
'username' => 'Skim', |
174
|
|
|
|
|
|
|
), |
175
|
|
|
|
|
|
|
Toolforge::MixNMatch::Object::User->new( |
176
|
|
|
|
|
|
|
'count' => 4, |
177
|
|
|
|
|
|
|
'uid' => 2, |
178
|
|
|
|
|
|
|
'username' => 'Foo', |
179
|
|
|
|
|
|
|
), |
180
|
|
|
|
|
|
|
], |
181
|
|
|
|
|
|
|
'year_months' => [ |
182
|
|
|
|
|
|
|
Toolforge::MixNMatch::Object::YearMonth->new( |
183
|
|
|
|
|
|
|
'count' => 2, |
184
|
|
|
|
|
|
|
'month' => 9, |
185
|
|
|
|
|
|
|
'year' => 2020, |
186
|
|
|
|
|
|
|
), |
187
|
|
|
|
|
|
|
Toolforge::MixNMatch::Object::YearMonth->new( |
188
|
|
|
|
|
|
|
'count' => 8, |
189
|
|
|
|
|
|
|
'month' => 10, |
190
|
|
|
|
|
|
|
'year' => 2020, |
191
|
|
|
|
|
|
|
), |
192
|
|
|
|
|
|
|
], |
193
|
|
|
|
|
|
|
); |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
# Get count. |
196
|
|
|
|
|
|
|
my $count = $obj->count; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# Get type. |
199
|
|
|
|
|
|
|
my $type = $obj->type; |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
# Get year months stats. |
202
|
|
|
|
|
|
|
my $year_months_ar = $obj->year_months; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# Get users. |
205
|
|
|
|
|
|
|
my $users_ar = $obj->users; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# Print out. |
208
|
|
|
|
|
|
|
print "Count: $count\n"; |
209
|
|
|
|
|
|
|
print "Type: $type\n"; |
210
|
|
|
|
|
|
|
print "Number of month/year statistics: ".(scalar @{$year_months_ar})."\n"; |
211
|
|
|
|
|
|
|
print "Number of users: ".(scalar @{$users_ar})."\n"; |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
# Output: |
214
|
|
|
|
|
|
|
# Count: 10 |
215
|
|
|
|
|
|
|
# Type: Q5 |
216
|
|
|
|
|
|
|
# Number of month/year statistics: 2 |
217
|
|
|
|
|
|
|
# Number of users: 2 |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
L<Mo>, |
222
|
|
|
|
|
|
|
L<Mo::utils>. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 SEE ALSO |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=over |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item L<Toolforge::MixNMatch::Object> |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Toolforge Mix'n'match tool objects. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=back |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 REPOSITORY |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Toolforge-MixNMatch-Object> |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 AUTHOR |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
L<http://skim.cz> |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
© Michal Josef Špaček 2020 |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
BSD 2-Clause License |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head1 VERSION |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
0.03 |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=cut |