line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Toolforge::MixNMatch::Print::Catalog; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
261171
|
use strict; |
|
3
|
|
|
|
|
26
|
|
|
3
|
|
|
|
|
86
|
|
4
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
83
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
984
|
use Error::Pure qw(err); |
|
3
|
|
|
|
|
23985
|
|
|
3
|
|
|
|
|
84
|
|
7
|
3
|
|
|
3
|
|
1550
|
use Indent; |
|
3
|
|
|
|
|
53632
|
|
|
3
|
|
|
|
|
96
|
|
8
|
3
|
|
|
3
|
|
1438
|
use Toolforge::MixNMatch::Print::User; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
95
|
|
9
|
3
|
|
|
3
|
|
1340
|
use Toolforge::MixNMatch::Print::YearMonth; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
1187
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.04; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub print { |
14
|
9
|
|
|
9
|
1
|
9142
|
my ($obj, $opts_hr) = @_; |
15
|
|
|
|
|
|
|
|
16
|
9
|
100
|
|
|
|
27
|
if (! defined $obj) { |
17
|
1
|
|
|
|
|
5
|
err "Object doesn't exist."; |
18
|
|
|
|
|
|
|
} |
19
|
8
|
100
|
|
|
|
38
|
if (! $obj->isa('Toolforge::MixNMatch::Object::Catalog')) { |
20
|
1
|
|
|
|
|
5
|
err "Object isn't 'Toolforge::MixNMatch::Object::Catalog'."; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
7
|
100
|
|
|
|
15
|
if (! defined $opts_hr) { |
24
|
5
|
|
|
|
|
19
|
$opts_hr = { |
25
|
|
|
|
|
|
|
'type' => 1, |
26
|
|
|
|
|
|
|
'count' => 1, |
27
|
|
|
|
|
|
|
'year_months' => 1, |
28
|
|
|
|
|
|
|
'users' => 1, |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my @print = ( |
33
|
|
|
|
|
|
|
$opts_hr->{'type'} ? 'Type: '.$obj->type : (), |
34
|
7
|
100
|
|
|
|
29
|
$opts_hr->{'count'} ? 'Count: '.$obj->count : (), |
|
|
100
|
|
|
|
|
|
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
7
|
|
|
|
|
96
|
my $i; |
38
|
|
|
|
|
|
|
|
39
|
7
|
100
|
100
|
|
|
21
|
if ($opts_hr->{'year_months'} && @{$obj->year_months}) { |
|
5
|
|
|
|
|
13
|
|
40
|
2
|
|
33
|
|
|
34
|
$i //= Indent->new; |
41
|
2
|
|
|
|
|
45
|
push @print, 'Year/months:'; |
42
|
2
|
|
|
|
|
6
|
$i->add; |
43
|
2
|
0
|
|
|
|
18
|
foreach my $year_month (sort { $a->year <=> $b->year || $a->month <=> $b->month } |
|
2
|
|
|
|
|
22
|
|
44
|
2
|
|
|
|
|
7
|
@{$obj->year_months}) { |
45
|
|
|
|
|
|
|
|
46
|
4
|
|
|
|
|
57
|
push @print, $i->get.Toolforge::MixNMatch::Print::YearMonth::print($year_month); |
47
|
|
|
|
|
|
|
} |
48
|
2
|
|
|
|
|
5
|
$i->remove; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
7
|
100
|
100
|
|
|
75
|
if ($opts_hr->{'users'} && @{$obj->users}) { |
|
5
|
|
|
|
|
11
|
|
52
|
2
|
|
66
|
|
|
28
|
$i //= Indent->new; |
53
|
2
|
|
|
|
|
34
|
push @print, 'Users:'; |
54
|
2
|
|
|
|
|
6
|
$i->add; |
55
|
2
|
|
|
|
|
19
|
foreach my $user (reverse sort { $a->count <=> $b->count } @{$obj->users}) { |
|
2
|
|
|
|
|
20
|
|
|
2
|
|
|
|
|
5
|
|
56
|
4
|
|
|
|
|
30
|
push @print, $i->get.Toolforge::MixNMatch::Print::User::print($user); |
57
|
|
|
|
|
|
|
} |
58
|
2
|
|
|
|
|
5
|
$i->remove; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
7
|
100
|
|
|
|
98
|
return wantarray ? @print : (join "\n", @print); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=pod |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=encoding utf8 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Toolforge::MixNMatch::Print::Catalog - Mix'n'match catalog structure print. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
use Toolforge::MixNMatch::Print::Catalog qw(print); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $print = print($obj); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SUBROUTINES |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 C<print> |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $print = print($obj); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Print Toolforge::MixNMatch::Object::Catalog instance to user output. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Returns string. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 ERRORS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
obj2struct(): |
95
|
|
|
|
|
|
|
Object doesn't exist. |
96
|
|
|
|
|
|
|
Object isn't 'Toolforge::MixNMatch::Object::Catalog'. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 EXAMPLE |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
use strict; |
101
|
|
|
|
|
|
|
use warnings; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
use Data::Printer; |
104
|
|
|
|
|
|
|
use Toolforge::MixNMatch::Object::Catalog; |
105
|
|
|
|
|
|
|
use Toolforge::MixNMatch::Object::User; |
106
|
|
|
|
|
|
|
use Toolforge::MixNMatch::Object::YearMonth; |
107
|
|
|
|
|
|
|
use Toolforge::MixNMatch::Print::Catalog; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Object. |
110
|
|
|
|
|
|
|
my $obj = Toolforge::MixNMatch::Object::Catalog->new( |
111
|
|
|
|
|
|
|
'count' => 10, |
112
|
|
|
|
|
|
|
'type' => 'Q5', |
113
|
|
|
|
|
|
|
'users' => [ |
114
|
|
|
|
|
|
|
Toolforge::MixNMatch::Object::User->new( |
115
|
|
|
|
|
|
|
'count' => 6, |
116
|
|
|
|
|
|
|
'uid' => 1, |
117
|
|
|
|
|
|
|
'username' => 'Skim', |
118
|
|
|
|
|
|
|
), |
119
|
|
|
|
|
|
|
Toolforge::MixNMatch::Object::User->new( |
120
|
|
|
|
|
|
|
'count' => 4, |
121
|
|
|
|
|
|
|
'uid' => 2, |
122
|
|
|
|
|
|
|
'username' => 'Foo', |
123
|
|
|
|
|
|
|
), |
124
|
|
|
|
|
|
|
], |
125
|
|
|
|
|
|
|
'year_months' => [ |
126
|
|
|
|
|
|
|
Toolforge::MixNMatch::Object::YearMonth->new( |
127
|
|
|
|
|
|
|
'count' => 2, |
128
|
|
|
|
|
|
|
'month' => 9, |
129
|
|
|
|
|
|
|
'year' => 2020, |
130
|
|
|
|
|
|
|
), |
131
|
|
|
|
|
|
|
Toolforge::MixNMatch::Object::YearMonth->new( |
132
|
|
|
|
|
|
|
'count' => 8, |
133
|
|
|
|
|
|
|
'month' => 10, |
134
|
|
|
|
|
|
|
'year' => 2020, |
135
|
|
|
|
|
|
|
), |
136
|
|
|
|
|
|
|
], |
137
|
|
|
|
|
|
|
); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# Print. |
140
|
|
|
|
|
|
|
print Toolforge::MixNMatch::Print::Catalog::print($obj)."\n"; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# Output: |
143
|
|
|
|
|
|
|
# Type: Q5 |
144
|
|
|
|
|
|
|
# Count: 10 |
145
|
|
|
|
|
|
|
# Year/months: |
146
|
|
|
|
|
|
|
# 2020/9: 2 |
147
|
|
|
|
|
|
|
# 2020/10: 8 |
148
|
|
|
|
|
|
|
# Users: |
149
|
|
|
|
|
|
|
# Skim (1): 6 |
150
|
|
|
|
|
|
|
# Foo (2): 4 |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L<Error::Pure>. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 SEE ALSO |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=over |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item L<Toolforge::MixNMatch::Print> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Toolforge Mix'n'match tool object print routines. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=back |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 REPOSITORY |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Toolforge-MixNMatch-Print> |
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
|
|
|
|
|
|
|
© Michal Josef Špaček 2020 |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
BSD 2-Clause License |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 VERSION |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
0.04 |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |