line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Jenkins::i18n::FindResults; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
69898
|
use 5.014004; |
|
9
|
|
|
|
|
41
|
|
4
|
9
|
|
|
9
|
|
51
|
use strict; |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
194
|
|
5
|
9
|
|
|
9
|
|
48
|
use warnings; |
|
9
|
|
|
|
|
28
|
|
|
9
|
|
|
|
|
295
|
|
6
|
9
|
|
|
9
|
|
4483
|
use Hash::Util qw(lock_keys); |
|
9
|
|
|
|
|
23758
|
|
|
9
|
|
|
|
|
62
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=pod |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Jenkins::i18n::FindResults - class that represents the results of |
13
|
|
|
|
|
|
|
Jenkins::i18n::find_files |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 METHODS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 new |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Creates and returns an instance. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
No parameter is expected. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
3
|
|
|
3
|
1
|
92
|
my $class = shift; |
29
|
3
|
|
|
|
|
14
|
my $self = { |
30
|
|
|
|
|
|
|
files => [], |
31
|
|
|
|
|
|
|
warnings => [] |
32
|
|
|
|
|
|
|
}; |
33
|
3
|
|
|
|
|
8
|
bless $self, $class; |
34
|
3
|
|
|
|
|
7
|
lock_keys( %{$self} ); |
|
3
|
|
|
|
|
24
|
|
35
|
3
|
|
|
|
|
61
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 add_file |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Adds a file to the files set. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Expects a string as parameters. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Return nothing. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub add_file { |
49
|
9
|
|
|
9
|
1
|
607
|
my ( $self, $file_path ) = @_; |
50
|
9
|
|
|
|
|
14
|
push( @{ $self->{files} }, $file_path ); |
|
9
|
|
|
|
|
112
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 add_warning |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Adds a warning to the warnings set. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Expects as parameters a string. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Return nothing. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub add_warning { |
64
|
5
|
|
|
5
|
1
|
50
|
my ( $self, $warning ) = @_; |
65
|
5
|
|
|
|
|
9
|
push( @{ $self->{warnings} }, $warning ); |
|
5
|
|
|
|
|
99
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _generic_iterator { |
69
|
3
|
|
|
3
|
|
11
|
my ( $self, $items_ref ) = @_; |
70
|
3
|
|
|
|
|
7
|
my $current_index = -1; |
71
|
3
|
|
|
|
|
6
|
my $last_index = scalar( @{$items_ref} ) - 1; |
|
3
|
|
|
|
|
7
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return sub { |
74
|
11
|
100
|
|
11
|
|
1148
|
return if ( $current_index == $last_index ); |
75
|
9
|
|
|
|
|
15
|
$current_index++; |
76
|
9
|
|
|
|
|
21
|
return $items_ref->[$current_index]; |
77
|
|
|
|
|
|
|
} |
78
|
3
|
|
|
|
|
28
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 files |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Returns an iterator for the files set, as a C reference. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The iterator will return C when there are no more elements so you can |
85
|
|
|
|
|
|
|
use it inside an C loop. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
The iterator only moves foward and the items will be alphabetically sorted. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Adding new files to the set after an iterator is created won't update it |
90
|
|
|
|
|
|
|
automatically, one will need to create a new one with this method. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Expects no parameter. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub files { |
97
|
3
|
|
|
3
|
1
|
13
|
my $self = shift; |
98
|
3
|
|
|
|
|
6
|
my @sorted = sort( @{ $self->{files} } ); |
|
3
|
|
|
|
|
19
|
|
99
|
3
|
|
|
|
|
12
|
return $self->_generic_iterator( \@sorted ); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 warnings |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns an iterator for the warnings set, as a C reference. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
The iterator will return C when there are no more elements so you can |
107
|
|
|
|
|
|
|
use it inside an C loop. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
The iterator only moves foward, the order of items will be in the sequence of |
110
|
|
|
|
|
|
|
registry of each warning. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Adding new files to the set after an iterator is created won't update it |
113
|
|
|
|
|
|
|
automatically, one will need to create a new one with this method. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Expects no parameter. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub warnings { |
120
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
121
|
0
|
|
|
|
|
0
|
return $self->_generic_iterator( $self->{warnings} ); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 size |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Returns a integer with the total of elements for the files. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub size { |
131
|
2
|
|
|
2
|
1
|
9
|
my $self = shift; |
132
|
2
|
|
|
|
|
4
|
return scalar( @{ $self->{files} } ); |
|
2
|
|
|
|
|
10
|
|
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 SEE ALSO |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=over |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=back |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |
148
|
|
|
|
|
|
|
__END__ |