line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::ProfilePrototype; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1092
|
use 5.006001; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
19
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use English qw(-no_match_vars); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
379
|
use Perl::ToPerl6::Config qw{}; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
13
|
|
10
|
1
|
|
|
1
|
|
5
|
use Perl::ToPerl6::Transformer qw{}; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
11
|
1
|
|
|
1
|
|
5
|
use Perl::ToPerl6::Utils qw{ :characters }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
12
|
1
|
|
|
1
|
|
310
|
use overload ( q{""} => 'to_string' ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
1
|
|
|
1
|
1
|
1398
|
my ($class, %args) = @_; |
18
|
1
|
|
|
|
|
3
|
my $self = bless {}, $class; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
50
|
|
|
9
|
my $transformers = $args{-transformers} || []; |
21
|
1
|
|
|
|
|
2
|
$self->{_transformers} = [ sort _by_type @{ $transformers } ]; |
|
1
|
|
|
|
|
32
|
|
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
3
|
my $comment_out_parameters = $args{'-comment-out-parameters'}; |
24
|
1
|
50
|
|
|
|
3
|
if (not defined $comment_out_parameters) { |
25
|
1
|
|
|
|
|
4
|
$comment_out_parameters = 1; |
26
|
|
|
|
|
|
|
} |
27
|
1
|
|
|
|
|
4
|
$self->{_comment_out_parameters} = $comment_out_parameters; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
2
|
my $configuration = $args{'-config'}; |
30
|
1
|
50
|
|
|
|
3
|
if (not $configuration) { |
31
|
1
|
|
|
|
|
12
|
$configuration = Perl::ToPerl6::Config->new(-profile => $EMPTY); |
32
|
|
|
|
|
|
|
} |
33
|
1
|
|
|
|
|
4
|
$self->{_configuration} = $configuration; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
5
|
return $self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _get_transformers { |
42
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return $self->{_transformers}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _comment_out_parameters { |
48
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $self->{_comment_out_parameters}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _configuration { |
54
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return $self->{_configuration}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _line_prefix { |
62
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
return $self->_comment_out_parameters() ? q{# } : $EMPTY; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub to_string { |
70
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $prefix = $self->_line_prefix(); |
73
|
0
|
|
|
|
|
|
my $configuration = $self->_configuration(); |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $prototype = "# Globals\n"; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
78
|
0
|
|
|
|
|
|
$prototype .= q{necessity = }; |
79
|
0
|
|
|
|
|
|
$prototype .= $configuration->necessity(); |
80
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
83
|
0
|
|
|
|
|
|
$prototype .= q{detail = }; |
84
|
0
|
|
|
|
|
|
$prototype .= $configuration->detail(); |
85
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
88
|
0
|
|
|
|
|
|
$prototype .= q{force = }; |
89
|
0
|
|
|
|
|
|
$prototype .= $configuration->force(); |
90
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
93
|
0
|
|
|
|
|
|
$prototype .= q{in-place = }; |
94
|
0
|
|
|
|
|
|
$prototype .= $configuration->in_place(); |
95
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
98
|
0
|
|
|
|
|
|
$prototype .= q{only = }; |
99
|
0
|
|
|
|
|
|
$prototype .= $configuration->only(); |
100
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
103
|
0
|
|
|
|
|
|
$prototype .= q{profile-strictness = }; |
104
|
0
|
|
|
|
|
|
$prototype .= $configuration->profile_strictness(); |
105
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
108
|
0
|
|
|
|
|
|
$prototype .= q{color = }; |
109
|
0
|
|
|
|
|
|
$prototype .= $configuration->color(); |
110
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
113
|
0
|
|
|
|
|
|
$prototype .= q{pager = }; |
114
|
0
|
|
|
|
|
|
$prototype .= $configuration->pager(); |
115
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
118
|
0
|
|
|
|
|
|
$prototype .= q{top = }; |
119
|
0
|
|
|
|
|
|
$prototype .= $configuration->top(); |
120
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
123
|
0
|
|
|
|
|
|
$prototype .= q{verbose = }; |
124
|
0
|
|
|
|
|
|
$prototype .= $configuration->verbose(); |
125
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
128
|
0
|
|
|
|
|
|
$prototype .= q{include = }; |
129
|
0
|
|
|
|
|
|
$prototype .= join $SPACE, $configuration->include(); |
130
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
133
|
0
|
|
|
|
|
|
$prototype .= q{exclude = }; |
134
|
0
|
|
|
|
|
|
$prototype .= join $SPACE, $configuration->exclude(); |
135
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
138
|
0
|
|
|
|
|
|
$prototype .= q{single-transformer = }; |
139
|
0
|
|
|
|
|
|
$prototype .= join $SPACE, $configuration->single_transformer(); |
140
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
143
|
0
|
|
|
|
|
|
$prototype .= q{theme = }; |
144
|
0
|
|
|
|
|
|
$prototype .= $configuration->theme()->rule(); |
145
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
foreach my $item (qw< |
148
|
|
|
|
|
|
|
color-necessity-highest |
149
|
|
|
|
|
|
|
color-necessity-high |
150
|
|
|
|
|
|
|
color-necessity-medium |
151
|
|
|
|
|
|
|
color-necessity-low |
152
|
|
|
|
|
|
|
color-necessity-lowest |
153
|
|
|
|
|
|
|
>) { |
154
|
0
|
|
|
|
|
|
( my $accessor = $item ) =~ s/ - /_/gmsx; |
155
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
156
|
0
|
|
|
|
|
|
$prototype .= "$item = "; |
157
|
0
|
|
|
|
|
|
$prototype .= $configuration->$accessor; |
158
|
0
|
|
|
|
|
|
$prototype .= "\n"; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
$prototype .= $prefix; |
162
|
0
|
|
|
|
|
|
$prototype .= q{program-extensions = }; |
163
|
0
|
|
|
|
|
|
$prototype .= join $SPACE, $configuration->program_extensions(); |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
Perl::ToPerl6::Transformer::set_format( $self->_proto_format() ); |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
my $transformer_prototypes = join qq{\n}, map { "$_" } @{ $self->_get_transformers() }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
$transformer_prototypes =~ s/\s+ \z//xms; # Trim trailing whitespace |
169
|
0
|
|
|
|
|
|
return $prototype . "\n\n" . $transformer_prototypes . "\n"; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# About "%{\\n%\\x7b# \\x7df\n${prefix}%n = %D\\n}O" below: |
175
|
|
|
|
|
|
|
# |
176
|
|
|
|
|
|
|
# The %0 format for a transformer specifies how to format parameters. |
177
|
|
|
|
|
|
|
# For a parameter %f specifies the full description. |
178
|
|
|
|
|
|
|
# |
179
|
|
|
|
|
|
|
# The problem is that both of these need to take options, but String::Format |
180
|
|
|
|
|
|
|
# doesn't allow nesting of {}. So, to get the option to the %f, the braces |
181
|
|
|
|
|
|
|
# are hex encoded. I.e., assuming that comment_out_parameters is in effect, |
182
|
|
|
|
|
|
|
# the parameter sees: |
183
|
|
|
|
|
|
|
# |
184
|
|
|
|
|
|
|
# \n%{# }f\n# %n = %D\n |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub _proto_format { |
187
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
188
|
|
|
|
|
|
|
|
189
|
0
|
|
|
|
|
|
my $prefix = $self->_line_prefix(); |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
return <<"END_OF_FORMAT"; |
192
|
|
|
|
|
|
|
# %a |
193
|
|
|
|
|
|
|
[%p] |
194
|
|
|
|
|
|
|
${prefix}set_themes = %t |
195
|
|
|
|
|
|
|
${prefix}add_themes = |
196
|
|
|
|
|
|
|
${prefix}necessity = %s |
197
|
|
|
|
|
|
|
%{\\n%\\x7b# \\x7df\\n${prefix}%n = %D\\n}O%{${prefix}Cannot programmatically discover what parameters this transformer takes.\\n}U |
198
|
|
|
|
|
|
|
END_OF_FORMAT |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
203
|
|
|
|
|
|
|
|
204
|
0
|
|
|
0
|
|
|
sub _by_type { return ref $a cmp ref $b } |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
1; |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
__END__ |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=pod |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 NAME |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Perl::ToPerl6::ProfilePrototype - Generate an initial Perl::ToPerl6 profile. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 DESCRIPTION |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
This is a helper class that generates a prototype of a |
220
|
|
|
|
|
|
|
L<Perl::ToPerl6|Perl::ToPerl6> profile (e.g. a F<.perlmogrifyrc> file. |
221
|
|
|
|
|
|
|
There are no user-serviceable parts here. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 INTERFACE SUPPORT |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
This is considered to be a non-public class. Its interface is subject |
227
|
|
|
|
|
|
|
to change without notice. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=over |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=item C<< new( -transformers => \@TRANSFORMER_OBJECTS ) >> |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Returns a reference to a new C<Perl::ToPerl6::ProfilePrototype> object. |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=back |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 METHODS |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=over |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=item to_string() |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Returns a string representation of this C<ProfilePrototype>. See |
249
|
|
|
|
|
|
|
L<"OVERLOADS"> for more information. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=back |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head1 OVERLOADS |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
When a |
258
|
|
|
|
|
|
|
L<Perl::ToPerl6::ProfilePrototype|Perl::ToPerl6::ProfilePrototype> is |
259
|
|
|
|
|
|
|
evaluated in string context, it produces a multi-line summary of the |
260
|
|
|
|
|
|
|
transformer name, default themes, and default necessity for each |
261
|
|
|
|
|
|
|
L<Perl::ToPerl6::Transformer|Perl::ToPerl6::Transformer> object that was given to |
262
|
|
|
|
|
|
|
the constructor of this C<ProfilePrototype>. If the Transformer supports |
263
|
|
|
|
|
|
|
an additional parameters, they will also be listed (but |
264
|
|
|
|
|
|
|
commented-out). The format is suitable for use as a F<.perlmogrifyrc> |
265
|
|
|
|
|
|
|
file. |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 AUTHOR |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head1 COPYRIGHT |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved. |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
278
|
|
|
|
|
|
|
it under the same terms as Perl itself. The full text of this license |
279
|
|
|
|
|
|
|
can be found in the LICENSE file included with this module. |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=cut |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
# Local Variables: |
284
|
|
|
|
|
|
|
# mode: cperl |
285
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
286
|
|
|
|
|
|
|
# fill-column: 78 |
287
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
288
|
|
|
|
|
|
|
# c-indentation-style: bsd |
289
|
|
|
|
|
|
|
# End: |
290
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |