line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Jenkins::i18n::Stats; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
76313
|
use 5.014004; |
|
1
|
|
|
|
|
8
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
6
|
1
|
|
|
1
|
|
540
|
use Hash::Util qw(lock_keys); |
|
1
|
|
|
|
|
2982
|
|
|
1
|
|
|
|
|
6
|
|
7
|
1
|
|
|
1
|
|
85
|
use Carp qw(confess); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
442
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=pod |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Jenkins::i18n::Stats - class to provide translations processing statistics |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Jenkins::i18n::Stats; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
C |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 EXPORT |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
None by default. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
All attributes are counters. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=over |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item * |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
files: all the found translation files. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item * |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
keys: all the keys loaded from the properties files. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item * |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
missing: all keys that are missing after comparing a language to the original |
46
|
|
|
|
|
|
|
in English, |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item * |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
unused: all keys that are available in the a language but not in the original |
51
|
|
|
|
|
|
|
English. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item * |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
empty: all keys in the language that are available but doesn't actually have a |
56
|
|
|
|
|
|
|
translated value. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item * |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
same: all keys that have the same values as the original in English. Not |
61
|
|
|
|
|
|
|
necessarilly an error. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item * |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
no_jenkins: all keys that are not related to Jenkins, but coming from Hudson. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=back |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 METHODS |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 new |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Creates a new instance. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub new { |
78
|
1
|
|
|
1
|
1
|
738
|
my $class = shift; |
79
|
1
|
|
|
|
|
7
|
my $self = { |
80
|
|
|
|
|
|
|
files => 0, |
81
|
|
|
|
|
|
|
keys => 0, |
82
|
|
|
|
|
|
|
missing => 0, |
83
|
|
|
|
|
|
|
unused => 0, |
84
|
|
|
|
|
|
|
empty => 0, |
85
|
|
|
|
|
|
|
same => 0, |
86
|
|
|
|
|
|
|
no_jenkins => 0 |
87
|
|
|
|
|
|
|
}; |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
3
|
bless $self, $class; |
90
|
1
|
|
|
|
|
2
|
lock_keys( %{$self} ); |
|
1
|
|
|
|
|
8
|
|
91
|
1
|
|
|
|
|
22
|
return $self; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 inc |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Increments a counter. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub inc { |
101
|
3
|
|
|
3
|
1
|
670
|
my ( $self, $item ) = @_; |
102
|
3
|
100
|
|
|
|
16
|
confess "item is a required parameter" unless ($item); |
103
|
|
|
|
|
|
|
confess "there is no such counter '$item'" |
104
|
2
|
100
|
|
|
|
25
|
unless ( exists( $self->{$item} ) ); |
105
|
1
|
|
|
|
|
3
|
$self->{$item}++; |
106
|
1
|
|
|
|
|
4
|
return 1; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub _done { |
110
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
111
|
|
|
|
|
|
|
return ( $self->{keys} |
112
|
|
|
|
|
|
|
- $self->{missing} |
113
|
|
|
|
|
|
|
- $self->{unused} |
114
|
|
|
|
|
|
|
- $self->{empty} |
115
|
|
|
|
|
|
|
- $self->{same} |
116
|
0
|
|
|
|
|
0
|
- $self->{no_jenkins} ); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 perc_done |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Calculates how much of the translation is completed. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Requires no parameters. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Returns a float as the percentage of the translation that is completed. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub perc_done { |
130
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
131
|
0
|
|
|
|
|
0
|
return ( ( $self->_done / $self->{keys} ) * 100 ); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 summary |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Returns a summary of all statistics in text format. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The summary is returned as a hash reference. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub summary { |
143
|
1
|
|
|
1
|
1
|
22
|
my $self = shift; |
144
|
|
|
|
|
|
|
|
145
|
1
|
50
|
|
|
|
5
|
unless ( $self->{keys} == 0 ) { |
146
|
0
|
|
|
|
|
0
|
my %summary = ( done => $self->_done, pdone => $self->perc_done ); |
147
|
0
|
|
|
|
|
0
|
my @wanted = qw(missing unused empty same no_jenkins); |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
0
|
foreach my $wanted (@wanted) { |
150
|
0
|
|
|
|
|
0
|
$summary{$wanted} = $self->{$wanted}; |
151
|
0
|
|
|
|
|
0
|
$summary{"p$wanted"} = $self->{$wanted} / $self->{keys} * 100; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
0
|
return \%summary; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
1
|
|
|
|
|
11
|
warn "Not a single key was processed\n"; |
159
|
1
|
|
|
|
|
13
|
return {}; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 files |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Getter for the C attribute. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub files { |
169
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
170
|
0
|
|
|
|
|
|
return $self->{files}; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
1; |
174
|
|
|
|
|
|
|
__END__ |