line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ZConf::DevTemplate; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
25601
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
5
|
1
|
|
|
1
|
|
558
|
use ZConf::template; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
6
|
1
|
|
|
1
|
|
642
|
use ZConf::template::GUI; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
35
|
|
7
|
1
|
|
|
1
|
|
861
|
use String::ShellQuote; |
|
1
|
|
|
|
|
908
|
|
|
1
|
|
|
|
|
2134
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
ZConf::DevTemplate - Creates a the basic framework for a ZConf based module. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.1.1 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.1.1'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use ZConf::DevTemplate; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $zcdt = ZConf::DevTemplate->new(); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 new |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new{ |
35
|
0
|
|
|
0
|
1
|
|
my %args; |
36
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
37
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
0
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $self={error=>undef, perror=>undef, errorString=>undef, module=>'ZConf-DevTemplate'}; |
41
|
0
|
|
|
|
|
|
bless $self; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return $self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 create |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This creates a new module. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head3 args hash |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head4 name |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This is the name of the module. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head4 email |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This is the email address of the author. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head4 author |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This is author's name. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head4 config |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This is the ZConf config the module will use. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $module=$zcdt->processGUI({ |
69
|
|
|
|
|
|
|
name=>'Some::Module', |
70
|
|
|
|
|
|
|
email=>'foo@bar', |
71
|
|
|
|
|
|
|
author=>'Foo Bar', |
72
|
|
|
|
|
|
|
config=>'someModule', |
73
|
|
|
|
|
|
|
}); |
74
|
|
|
|
|
|
|
if($zcdt->{error}){ |
75
|
|
|
|
|
|
|
print "Error!\n"; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub create{ |
81
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
82
|
0
|
|
|
|
|
|
my %args; |
83
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
84
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
0
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
86
|
0
|
|
|
|
|
|
my $function='create'; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
$self->errorblank; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
#make sure a name is specified |
91
|
0
|
0
|
|
|
|
|
if (!defined( $args{name} )) { |
92
|
0
|
|
|
|
|
|
$self->{error}=1; |
93
|
0
|
|
|
|
|
|
$self->{errorString}='No name for the module specified'; |
94
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
95
|
0
|
|
|
|
|
|
return undef; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
#make sure a name is specified |
99
|
0
|
0
|
|
|
|
|
if (!defined( $args{email} )) { |
100
|
0
|
|
|
|
|
|
$self->{error}=1; |
101
|
0
|
|
|
|
|
|
$self->{errorString}='No email for author specified'; |
102
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
103
|
0
|
|
|
|
|
|
return undef; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
#make sure a name is specified |
107
|
0
|
0
|
|
|
|
|
if (!defined( $args{config} )) { |
108
|
0
|
|
|
|
|
|
$self->{error}=1; |
109
|
0
|
|
|
|
|
|
$self->{errorString}='No ZConf config specified'; |
110
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
111
|
0
|
|
|
|
|
|
return undef; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
#make sure a name is specified |
115
|
0
|
0
|
|
|
|
|
if (!defined( $args{author} )) { |
116
|
0
|
|
|
|
|
|
$self->{error}=1; |
117
|
0
|
|
|
|
|
|
$self->{errorString}='No name for the author specified'; |
118
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
119
|
0
|
|
|
|
|
|
return undef; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
#creates the module stuff |
123
|
0
|
|
|
|
|
|
system('module-starter --module='.shell_quote($args{name}).' --email='.shell_quote($args{email}).' --author='.shell_quote($args{author})); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
#processes the module |
126
|
0
|
|
|
|
|
|
my $module=$self->processTemplate(\%args); |
127
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
128
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': processTemplate errored'); |
129
|
0
|
|
|
|
|
|
return undef; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
#processes the GUI |
133
|
0
|
|
|
|
|
|
my $gui=$self->processGUI(\%args); |
134
|
0
|
0
|
|
|
|
|
if ($self->{error}) { |
135
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.': processGUI errored'); |
136
|
0
|
|
|
|
|
|
return undef; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
#writes out the module stuff |
140
|
0
|
|
|
|
|
|
my $modulepath=$args{name}.'/lib/'; |
141
|
0
|
|
|
|
|
|
$modulepath=~s/\:\:/\-/g; |
142
|
0
|
|
|
|
|
|
my $modulepath2=$args{name}; |
143
|
0
|
|
|
|
|
|
$modulepath2=~s/\:\:/\//g; |
144
|
0
|
|
|
|
|
|
$modulepath=$modulepath.$modulepath2.'.pm'; |
145
|
0
|
|
|
|
|
|
open(MODULE, '>', $modulepath); |
146
|
0
|
|
|
|
|
|
print MODULE $module; |
147
|
0
|
|
|
|
|
|
close(MODULE); |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
#writes out the GUI stuff |
150
|
0
|
|
|
|
|
|
my $guipath=$args{name}.'/lib/'; |
151
|
0
|
|
|
|
|
|
$guipath=~s/\:\:/\-/g; |
152
|
0
|
|
|
|
|
|
my $guipath2=$args{name}; |
153
|
0
|
|
|
|
|
|
$guipath2=~s/\:\:/\//g; |
154
|
0
|
|
|
|
|
|
mkdir($guipath.$guipath2); |
155
|
0
|
|
|
|
|
|
$guipath=$guipath.$guipath2.'/GUI.pm'; |
156
|
0
|
|
|
|
|
|
open(GUI, '>', $guipath); |
157
|
0
|
|
|
|
|
|
print GUI $gui; |
158
|
0
|
|
|
|
|
|
close(GUI); |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
return 1; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 processGUI |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This processes 'ZConf::template::GUI' and returns a string |
166
|
|
|
|
|
|
|
containing the module. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
It takes one arguement and that is a hash. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head3 args hash |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head4 name |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This is the name of the module. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head4 email |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This is the email address of the author. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head4 author |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This is author's name. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head4 config |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
This is the ZConf config the module will use. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
my $module=$zcdt->processGUI({ |
189
|
|
|
|
|
|
|
name=>'Some::Module', |
190
|
|
|
|
|
|
|
email=>'foo@bar', |
191
|
|
|
|
|
|
|
author=>'Foo Bar', |
192
|
|
|
|
|
|
|
config=>'someModule', |
193
|
|
|
|
|
|
|
}); |
194
|
|
|
|
|
|
|
if($zcdt->{error}){ |
195
|
|
|
|
|
|
|
print "Error!\n"; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub processGUI{ |
201
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
202
|
0
|
|
|
|
|
|
my %args; |
203
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
204
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
0
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
} |
206
|
0
|
|
|
|
|
|
my $function='processGUI'; |
207
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
$self->errorblank; |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
#make sure a name is specified |
211
|
0
|
0
|
|
|
|
|
if (!defined( $args{name} )) { |
212
|
0
|
|
|
|
|
|
$self->{error}=1; |
213
|
0
|
|
|
|
|
|
$self->{errorString}='No name for the module specified'; |
214
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
215
|
0
|
|
|
|
|
|
return undef; |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
#make sure a name is specified |
219
|
0
|
0
|
|
|
|
|
if (!defined( $args{email} )) { |
220
|
0
|
|
|
|
|
|
$self->{error}=1; |
221
|
0
|
|
|
|
|
|
$self->{errorString}='No email for author specified'; |
222
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
223
|
0
|
|
|
|
|
|
return undef; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
#make sure a name is specified |
227
|
0
|
0
|
|
|
|
|
if (!defined( $args{config} )) { |
228
|
0
|
|
|
|
|
|
$self->{error}=1; |
229
|
0
|
|
|
|
|
|
$self->{errorString}='No ZConf config specified'; |
230
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
231
|
0
|
|
|
|
|
|
return undef; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
#make sure a name is specified |
235
|
0
|
0
|
|
|
|
|
if (!defined( $args{author} )) { |
236
|
0
|
|
|
|
|
|
$self->{error}=1; |
237
|
0
|
|
|
|
|
|
$self->{errorString}='No name for the author specified'; |
238
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
239
|
0
|
|
|
|
|
|
return undef; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
0
|
|
|
|
|
|
my @lines; |
243
|
0
|
0
|
|
|
|
|
if (open(TEMPLATE, $INC{'ZConf/template/GUI.pm'})) { |
244
|
0
|
|
|
|
|
|
my $line=; |
245
|
0
|
|
|
|
|
|
while (defined($line)) { |
246
|
0
|
|
|
|
|
|
push(@lines, $line); |
247
|
0
|
|
|
|
|
|
$line=; |
248
|
|
|
|
|
|
|
} |
249
|
0
|
|
|
|
|
|
close(TEMPLATE); |
250
|
|
|
|
|
|
|
}else { |
251
|
0
|
|
|
|
|
|
$self->{error}=2; |
252
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to open "ZConf::template::GUI"'; |
253
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
254
|
0
|
|
|
|
|
|
return undef; |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
#put it together |
258
|
0
|
|
|
|
|
|
my $toreturn=join('', @lines); |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
#replace the module name |
261
|
0
|
|
|
|
|
|
my $regex='ZConf\:\:template\:\:GUI'; |
262
|
0
|
|
|
|
|
|
my $new=$args{name}.'::GUI'; |
263
|
0
|
|
|
|
|
|
$toreturn=~s/$regex/$new/g; |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
#replaces parent as well |
266
|
0
|
|
|
|
|
|
$regex='ZConf\:\:template'; |
267
|
0
|
|
|
|
|
|
$new=$args{name}; |
268
|
0
|
|
|
|
|
|
$toreturn=~s/$regex/$new/g; |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
#replaces other name |
271
|
0
|
|
|
|
|
|
$regex=quotemeta('ZConf-template-GUI'); |
272
|
0
|
|
|
|
|
|
$new=$args{name}.'::GUI'; |
273
|
0
|
|
|
|
|
|
$new=~s/\:\:/\-/g; |
274
|
0
|
|
|
|
|
|
$toreturn=~s/$regex/$new/g; |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
#replaces parent module info |
277
|
0
|
|
|
|
|
|
$regex='\%\%\%PARENT\%\%\%'; |
278
|
0
|
|
|
|
|
|
$new=$args{name}; |
279
|
0
|
|
|
|
|
|
$toreturn=~s/$regex/$new/g; |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
#replaces other name |
282
|
0
|
|
|
|
|
|
$regex='\%\%\%EMAIL\%\%\%'; |
283
|
0
|
|
|
|
|
|
$new=$args{email}; |
284
|
0
|
|
|
|
|
|
$new=~s/\@/ at /g; |
285
|
0
|
|
|
|
|
|
$toreturn=~s/$regex/$new/g; |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
#replaces other name |
288
|
0
|
|
|
|
|
|
$regex='\%\%\%ZCONFCONFIG\%\%\%'; |
289
|
0
|
|
|
|
|
|
$toreturn=~s/$regex/$args{config}/g; |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
#replaces other name |
292
|
0
|
|
|
|
|
|
$regex='\%\%\%AUTHOR\%\%\%'; |
293
|
0
|
|
|
|
|
|
$toreturn=~s/$regex/$args{author}/g; |
294
|
|
|
|
|
|
|
|
295
|
0
|
|
|
|
|
|
return $toreturn; |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=head2 processTemplate |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
This processes 'ZConf::template' and returns |
301
|
|
|
|
|
|
|
a string containing the new module. |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
It takes one arguement and that is a hash. |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head3 args hash |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=head4 name |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
This is the name of the module. |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=head4 email |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
This is the email address of the author. |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=head4 author |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
This is author's name. |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
=head4 config |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
This is the ZConf config the module will use. |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
my $module=$zcdt->processTemplate({ |
324
|
|
|
|
|
|
|
name=>'Some::Module', |
325
|
|
|
|
|
|
|
email=>'foo@bar', |
326
|
|
|
|
|
|
|
author=>'Foo Bar', |
327
|
|
|
|
|
|
|
config=>'someModule', |
328
|
|
|
|
|
|
|
}); |
329
|
|
|
|
|
|
|
if($zcdt->{error}){ |
330
|
|
|
|
|
|
|
print "Error!\n"; |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
=cut |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
sub processTemplate{ |
336
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
337
|
0
|
|
|
|
|
|
my %args; |
338
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
339
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
0
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
} |
341
|
0
|
|
|
|
|
|
my $function='processTemplate'; |
342
|
|
|
|
|
|
|
|
343
|
0
|
|
|
|
|
|
$self->errorblank; |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
#make sure a name is specified |
346
|
0
|
0
|
|
|
|
|
if (!defined( $args{name} )) { |
347
|
0
|
|
|
|
|
|
$self->{error}=1; |
348
|
0
|
|
|
|
|
|
$self->{errorString}='No name for the module specified'; |
349
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
350
|
0
|
|
|
|
|
|
return undef; |
351
|
|
|
|
|
|
|
} |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
#make sure a name is specified |
354
|
0
|
0
|
|
|
|
|
if (!defined( $args{email} )) { |
355
|
0
|
|
|
|
|
|
$self->{error}=1; |
356
|
0
|
|
|
|
|
|
$self->{errorString}='No email for author specified'; |
357
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
358
|
0
|
|
|
|
|
|
return undef; |
359
|
|
|
|
|
|
|
} |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
#make sure a name is specified |
362
|
0
|
0
|
|
|
|
|
if (!defined( $args{config} )) { |
363
|
0
|
|
|
|
|
|
$self->{error}=1; |
364
|
0
|
|
|
|
|
|
$self->{errorString}='No ZConf config specified'; |
365
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
366
|
0
|
|
|
|
|
|
return undef; |
367
|
|
|
|
|
|
|
} |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
#make sure a name is specified |
370
|
0
|
0
|
|
|
|
|
if (!defined( $args{author} )) { |
371
|
0
|
|
|
|
|
|
$self->{error}=1; |
372
|
0
|
|
|
|
|
|
$self->{errorString}='No name for the author specified'; |
373
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
374
|
0
|
|
|
|
|
|
return undef; |
375
|
|
|
|
|
|
|
} |
376
|
|
|
|
|
|
|
|
377
|
0
|
|
|
|
|
|
my @lines; |
378
|
0
|
0
|
|
|
|
|
if (open(TEMPLATE, $INC{'ZConf/template.pm'})) { |
379
|
0
|
|
|
|
|
|
my $line=; |
380
|
0
|
|
|
|
|
|
while (defined($line)) { |
381
|
0
|
|
|
|
|
|
push(@lines, $line); |
382
|
0
|
|
|
|
|
|
$line=; |
383
|
|
|
|
|
|
|
} |
384
|
0
|
|
|
|
|
|
close(TEMPLATE); |
385
|
|
|
|
|
|
|
}else { |
386
|
0
|
|
|
|
|
|
$self->{error}=2; |
387
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to open "ZConf::template"'; |
388
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$function.':'.$self->{error}.': '.$self->{errorString}); |
389
|
0
|
|
|
|
|
|
return undef; |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
#put it together |
393
|
0
|
|
|
|
|
|
my $toreturn=join('', @lines); |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
#replace the module name |
396
|
0
|
|
|
|
|
|
my $regex='ZConf\:\:template'; |
397
|
0
|
|
|
|
|
|
my $new=$args{name}; |
398
|
0
|
|
|
|
|
|
$toreturn=~s/$regex/$new/g; |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
#replaces other name |
401
|
0
|
|
|
|
|
|
$regex=quotemeta('ZConf-template'); |
402
|
0
|
|
|
|
|
|
$new=$args{name}; |
403
|
0
|
|
|
|
|
|
$new=~s/\:\:/\-/g; |
404
|
0
|
|
|
|
|
|
$toreturn=~s/$regex/$new/g; |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
#replaces other name |
407
|
0
|
|
|
|
|
|
$regex='\%\%\%EMAIL\%\%\%'; |
408
|
0
|
|
|
|
|
|
$new=$args{email}; |
409
|
0
|
|
|
|
|
|
$new=~s/\@/ at /g; |
410
|
0
|
|
|
|
|
|
$toreturn=~s/$regex/$new/g; |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
#replaces other name |
413
|
0
|
|
|
|
|
|
$regex='\%\%\%ZCONFCONFIG\%\%\%'; |
414
|
0
|
|
|
|
|
|
$toreturn=~s/$regex/$args{config}/g; |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
#replaces other name |
417
|
0
|
|
|
|
|
|
$regex='\%\%\%AUTHOR\%\%\%'; |
418
|
0
|
|
|
|
|
|
$toreturn=~s/$regex/$args{author}/g; |
419
|
|
|
|
|
|
|
|
420
|
0
|
|
|
|
|
|
return $toreturn; |
421
|
|
|
|
|
|
|
} |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
=head2 errorblank |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
This blanks the error storage and is only meant for internal usage. |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
It does the following. |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
$self->{error}=undef; |
430
|
|
|
|
|
|
|
$self->{errorString}=""; |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
=cut |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
#blanks the error flags |
435
|
|
|
|
|
|
|
sub errorblank{ |
436
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
437
|
|
|
|
|
|
|
|
438
|
0
|
0
|
|
|
|
|
if ($self->{perror}) { |
439
|
0
|
|
|
|
|
|
warn('ZConf-DevTemplate errorblank: A permanent error is set'); |
440
|
0
|
|
|
|
|
|
return undef; |
441
|
|
|
|
|
|
|
} |
442
|
|
|
|
|
|
|
|
443
|
0
|
|
|
|
|
|
$self->{error}=undef; |
444
|
0
|
|
|
|
|
|
$self->{errorString}=""; |
445
|
|
|
|
|
|
|
|
446
|
0
|
|
|
|
|
|
return 1; |
447
|
|
|
|
|
|
|
} |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
=head1 ERROR CODES |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
=head2 1 |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
Missing arguement. |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
=head2 2 |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
Could not open 'ZConf::template'; |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
=head1 AUTHOR |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=head1 BUGS |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
466
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
467
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
=head1 SUPPORT |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
perldoc ZConf::DevTemplate |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
You can also look for information at: |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
=over 4 |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
L |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
L |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
=item * CPAN Ratings |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
L |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
=item * Search CPAN |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
L |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
=back |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
Copyright 2009 Zane C. Bowers, all rights reserved. |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
510
|
|
|
|
|
|
|
under the same terms as Perl itself. |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
=cut |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
1; # End of ZConf::DevTemplate |