line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::TransformerConfig; |
2
|
|
|
|
|
|
|
|
3
|
25
|
|
|
25
|
|
988
|
use 5.006001; |
|
25
|
|
|
|
|
75
|
|
4
|
25
|
|
|
25
|
|
115
|
use strict; |
|
25
|
|
|
|
|
35
|
|
|
25
|
|
|
|
|
938
|
|
5
|
25
|
|
|
25
|
|
115
|
use warnings; |
|
25
|
|
|
|
|
31
|
|
|
25
|
|
|
|
|
743
|
|
6
|
|
|
|
|
|
|
|
7
|
25
|
|
|
25
|
|
672
|
use Readonly; |
|
25
|
|
|
|
|
2355
|
|
|
25
|
|
|
|
|
1936
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
10
|
|
|
|
|
|
|
|
11
|
25
|
|
|
25
|
|
4629
|
use Perl::ToPerl6::Exception::AggregateConfiguration; |
|
25
|
|
|
|
|
53
|
|
|
25
|
|
|
|
|
1285
|
|
12
|
25
|
|
|
25
|
|
10629
|
use Perl::ToPerl6::Exception::Configuration::Option::Transformer::ParameterValue; |
|
25
|
|
|
|
|
57
|
|
|
25
|
|
|
|
|
1326
|
|
13
|
25
|
|
|
25
|
|
9849
|
use Perl::ToPerl6::Exception::Configuration::Option::Transformer::ExtraParameter; |
|
25
|
|
|
|
|
51
|
|
|
25
|
|
|
|
|
1311
|
|
14
|
25
|
|
|
25
|
|
129
|
use Perl::ToPerl6::Utils qw< :booleans :characters severity_to_number >; |
|
25
|
|
|
|
|
34
|
|
|
25
|
|
|
|
|
1536
|
|
15
|
25
|
|
|
25
|
|
13925
|
use Perl::ToPerl6::Utils::Constants qw< :profile_strictness >; |
|
25
|
|
|
|
|
51
|
|
|
25
|
|
|
|
|
22487
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Readonly::Scalar my $NON_PUBLIC_DATA => '_non_public_data'; |
20
|
|
|
|
|
|
|
Readonly::Scalar my $NO_LIMIT => 'no_limit'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
2921
|
|
|
2921
|
0
|
4303
|
my ($class, $transformer_short_name, $specification) = @_; |
26
|
|
|
|
|
|
|
|
27
|
2921
|
100
|
|
|
|
4505
|
my %self = $specification ? %{ $specification } : (); |
|
2920
|
|
|
|
|
7016
|
|
28
|
2921
|
|
|
|
|
2742
|
my %non_public_data; |
29
|
|
|
|
|
|
|
|
30
|
2921
|
|
|
|
|
4274
|
$non_public_data{_transformer_short_name} = $transformer_short_name; |
31
|
|
|
|
|
|
|
$non_public_data{_profile_strictness} = |
32
|
2921
|
|
|
|
|
5316
|
$self{$NON_PUBLIC_DATA}{_profile_strictness}; |
33
|
|
|
|
|
|
|
|
34
|
2921
|
|
|
|
|
4548
|
foreach my $standard_parameter ( |
35
|
|
|
|
|
|
|
qw< maximum_transformations_per_document severity set_themes add_themes > |
36
|
|
|
|
|
|
|
) { |
37
|
11684
|
100
|
|
|
|
19950
|
if ( exists $self{$standard_parameter} ) { |
38
|
|
|
|
|
|
|
$non_public_data{"_$standard_parameter"} = |
39
|
172
|
|
|
|
|
499
|
delete $self{$standard_parameter}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
2921
|
|
|
|
|
3936
|
$self{$NON_PUBLIC_DATA} = \%non_public_data; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
2921
|
|
|
|
|
9066
|
return bless \%self, $class; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _get_non_public_data { |
52
|
5494
|
|
|
5494
|
|
4909
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
5494
|
|
|
|
|
10778
|
return $self->{$NON_PUBLIC_DATA}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub get_transformer_short_name { |
60
|
4
|
|
|
4
|
1
|
1314
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
4
|
|
|
|
|
14
|
return $self->_get_non_public_data()->{_transformer_short_name}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub get_set_themes { |
68
|
1372
|
|
|
1372
|
1
|
1355
|
my ($self) = @_; |
69
|
|
|
|
|
|
|
|
70
|
1372
|
|
|
|
|
2080
|
return $self->_get_non_public_data()->{_set_themes}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub get_add_themes { |
76
|
1372
|
|
|
1372
|
1
|
1408
|
my ($self) = @_; |
77
|
|
|
|
|
|
|
|
78
|
1372
|
|
|
|
|
2027
|
return $self->_get_non_public_data()->{_add_themes}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub get_severity { |
84
|
1373
|
|
|
1373
|
1
|
1432
|
my ($self) = @_; |
85
|
|
|
|
|
|
|
|
86
|
1373
|
|
|
|
|
2023
|
return $self->_get_non_public_data()->{_severity}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub is_maximum_transformations_per_document_unlimited { |
92
|
1371
|
|
|
1371
|
1
|
1575
|
my ($self) = @_; |
93
|
|
|
|
|
|
|
|
94
|
1371
|
|
|
|
|
2545
|
my $maximum_transformations = $self->get_maximum_transformations_per_document(); |
95
|
1371
|
50
|
66
|
|
|
4550
|
if ( |
|
|
|
66
|
|
|
|
|
96
|
|
|
|
|
|
|
not defined $maximum_transformations |
97
|
|
|
|
|
|
|
or $maximum_transformations eq $EMPTY |
98
|
|
|
|
|
|
|
or $maximum_transformations =~ m<\A $NO_LIMIT \z>xmsio |
99
|
|
|
|
|
|
|
) { |
100
|
1371
|
|
|
|
|
4533
|
return $TRUE; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
0
|
return $FALSE; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub get_maximum_transformations_per_document { |
109
|
1373
|
|
|
1373
|
1
|
1344
|
my ($self) = @_; |
110
|
|
|
|
|
|
|
|
111
|
1373
|
|
|
|
|
2881
|
return $self->_get_non_public_data()->{_maximum_transformations_per_document}; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub get { |
117
|
11
|
|
|
11
|
1
|
2677
|
my ($self, $parameter) = @_; |
118
|
|
|
|
|
|
|
|
119
|
11
|
100
|
|
|
|
35
|
return if $parameter eq $NON_PUBLIC_DATA; |
120
|
|
|
|
|
|
|
|
121
|
9
|
|
|
|
|
46
|
return $self->{$parameter}; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub remove { |
127
|
1
|
|
|
1
|
1
|
353
|
my ($self, $parameter) = @_; |
128
|
|
|
|
|
|
|
|
129
|
1
|
50
|
|
|
|
4
|
return if $parameter eq $NON_PUBLIC_DATA; |
130
|
|
|
|
|
|
|
|
131
|
1
|
|
|
|
|
2
|
delete $self->{$parameter}; |
132
|
|
|
|
|
|
|
|
133
|
1
|
|
|
|
|
2
|
return; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub is_empty { |
139
|
3
|
|
|
3
|
1
|
7
|
my ($self) = @_; |
140
|
|
|
|
|
|
|
|
141
|
3
|
|
|
|
|
3
|
return 1 >= keys %{$self}; |
|
3
|
|
|
|
|
16
|
|
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub get_parameter_names { |
147
|
1452
|
|
|
1452
|
1
|
1892
|
my ($self) = @_; |
148
|
|
|
|
|
|
|
|
149
|
1452
|
|
|
|
|
1589
|
return grep { $_ ne $NON_PUBLIC_DATA } keys %{$self}; |
|
1493
|
|
|
|
|
5213
|
|
|
1452
|
|
|
|
|
3759
|
|
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub handle_extra_parameters { |
155
|
1449
|
|
|
1449
|
1
|
1886
|
my ($self, $transformer, $errors) = @_; |
156
|
|
|
|
|
|
|
|
157
|
1449
|
|
|
|
|
2782
|
my $profile_strictness = $self->{$NON_PUBLIC_DATA}{_profile_strictness}; |
158
|
1449
|
100
|
|
|
|
3408
|
defined $profile_strictness |
159
|
|
|
|
|
|
|
or $profile_strictness = $PROFILE_STRICTNESS_DEFAULT; |
160
|
|
|
|
|
|
|
|
161
|
1449
|
50
|
|
|
|
2995
|
return if $profile_strictness eq $PROFILE_STRICTNESS_QUIET; |
162
|
|
|
|
|
|
|
|
163
|
1449
|
100
|
|
|
|
5747
|
my $parameter_errors = $profile_strictness eq $PROFILE_STRICTNESS_WARN ? |
164
|
|
|
|
|
|
|
Perl::ToPerl6::Exception::AggregateConfiguration->new() : $errors; |
165
|
|
|
|
|
|
|
|
166
|
1449
|
|
|
|
|
643325
|
foreach my $offered_param ( $self->get_parameter_names() ) { |
167
|
40
|
|
|
|
|
141
|
$parameter_errors->add_exception( |
168
|
|
|
|
|
|
|
Perl::ToPerl6::Exception::Configuration::Option::Transformer::ExtraParameter->new( |
169
|
|
|
|
|
|
|
transformer => $transformer->get_short_name(), |
170
|
|
|
|
|
|
|
option_name => $offered_param, |
171
|
|
|
|
|
|
|
source => undef, |
172
|
|
|
|
|
|
|
) |
173
|
|
|
|
|
|
|
); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
1449
|
100
|
100
|
|
|
6966
|
warn qq<$parameter_errors\n> |
177
|
|
|
|
|
|
|
if ($profile_strictness eq $PROFILE_STRICTNESS_WARN |
178
|
|
|
|
|
|
|
&& $parameter_errors->has_exceptions()); |
179
|
|
|
|
|
|
|
|
180
|
1449
|
|
|
|
|
41652
|
return; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub set_profile_strictness { |
186
|
1411
|
|
|
1411
|
1
|
1682
|
my ($self, $profile_strictness) = @_; |
187
|
|
|
|
|
|
|
|
188
|
1411
|
|
|
|
|
2653
|
$self->{$NON_PUBLIC_DATA}{_profile_strictness} = $profile_strictness; |
189
|
|
|
|
|
|
|
|
190
|
1411
|
|
|
|
|
2664
|
return; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
1; |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
__END__ |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=pod |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=for stopwords |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 NAME |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Perl::ToPerl6::TransformerConfig - Configuration data for a Transformer. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 DESCRIPTION |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
A container for the configuration of a Transformer. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 INTERFACE SUPPORT |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
This is considered to be a non-public class. Its interface is subject |
219
|
|
|
|
|
|
|
to change without notice. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 METHODS |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=over |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item C<get_transformer_short_name()> |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
The name of the transformer this configuration is for. Primarily here for |
229
|
|
|
|
|
|
|
the sake of debugging. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item C< get_set_themes() > |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
The value of C<set_themes> in the user's F<.perlmogrifyrc>. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item C< get_add_themes() > |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
The value of C<add_themes> in the user's F<.perlmogrifyrc>. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=item C< get_severity() > |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
The value of C<severity> in the user's F<.perlmogrifyrc>. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item C< is_maximum_transformations_per_document_unlimited() > |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Answer whether the value of C<maximum_transformations_per_document> should |
250
|
|
|
|
|
|
|
be considered to be unlimited. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=item C< get_maximum_transformations_per_document() > |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
The value of C<maximum_transformations_per_document> in the user's |
256
|
|
|
|
|
|
|
F<.perlmogrifyrc>. |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item C< get($parameter) > |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
Retrieve the value of the specified parameter in the user's |
262
|
|
|
|
|
|
|
F<.perlmogrifyrc>. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=item C< remove($parameter) > |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
Delete the value of the specified parameter. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=item C< is_empty() > |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Answer whether there is any non-standard configuration information |
273
|
|
|
|
|
|
|
left. |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=item C< get_parameter_names() > |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
Retrieve the names of the parameters in this object. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=item C< set_profile_strictness($profile_strictness) > |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
Sets the profile strictness associated with the configuration. |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=item C< handle_extra_parameters($transformer,$errors) > |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
Deals with any extra parameters according to the profile_strictness |
289
|
|
|
|
|
|
|
setting. To be called by Perl::ToPerl6::Transformer->new() once all valid |
290
|
|
|
|
|
|
|
transformers have been processed and removed from the configuration. |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
If profile_strictness is $PROFILE_STRICTNESS_QUIET, extra transformer |
293
|
|
|
|
|
|
|
parameters are ignored. |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
If profile_strictness is $PROFILE_STRICTNESS_WARN, extra transformer |
296
|
|
|
|
|
|
|
parameters generate a warning. |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
If profile_strictness is $PROFILE_STRICTNESS_FATAL, extra transformer |
299
|
|
|
|
|
|
|
parameters generate a fatal error. |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
If no profile_strictness was set, the behavior is that specified by |
302
|
|
|
|
|
|
|
$PROFILE_STRICTNESS_DEFAULT. |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=back |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=head1 SEE ALSO |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
L<Perl::ToPerl6::DEVELOPER/"MAKING YOUR POLICY CONFIGURABLE"> |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=head1 AUTHOR |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
Elliot Shank <perl@galumph.com> |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=head1 COPYRIGHT |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
Copyright (c) 2008-2011 Elliot Shank. |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
323
|
|
|
|
|
|
|
it under the same terms as Perl itself. The full text of this license |
324
|
|
|
|
|
|
|
can be found in the LICENSE file included with this module. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=cut |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
# Local Variables: |
329
|
|
|
|
|
|
|
# mode: cperl |
330
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
331
|
|
|
|
|
|
|
# fill-column: 78 |
332
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
333
|
|
|
|
|
|
|
# c-indentation-style: bsd |
334
|
|
|
|
|
|
|
# End: |
335
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |