blib/lib/oEdtk.pm untested

filter: Statementstmt 0.0% 0 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 25 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
oEdtk_release
2.0
END
2.0
CRAP 2.0
1 package oEdtk;
2  
3 use strict;
4  
5 BEGIN {
6 use Exporter;
7 use vars qw($VERSION $YEAR @ISA @EXPORT @EXPORT_OK); # %EXPORT_TAGS);
8  
9 # a.ammr a.a elapsed years, mm months, r release
10 $VERSION = '2.1129';
11 $YEAR = '2026';
12 @ISA = qw(Exporter);
13 @EXPORT = qw(oEdtk_release);
14  
15 print "(c) 2005-$YEAR oedtk\@free.fr - oEdtk v$VERSION\n";
16 }
17  
18 #
19 # CODE - DOC AT THE END
20 #
21  
22 sub oEdtk_release {
23  
24 # warn "DEBUG: >$?< \nDEBUG: >$@<\n";
25 return "(c) 2005-$YEAR oedtk\@free.fr - oEdtk v$VERSION\n";
26 }
27  
28 END {
29 }
30  
31 1;
32  
33 __END__
34  
35 # This document is in Pod format. To read this, use a Pod formatter, like
36 # "perldoc oEdtk".
37  
38 =head1 NAME
39  
40 oEdtk - A module for industrial printing processing
41  
42 =head1 DESCRIPTION
43  
44 This is the main module of the oEdtk toolkit. It's intended for documentation
45 purposes only. You will find general information about the diferents tools
46 here.
47  
48 =head1 LICENCE
49  
50 oEdtk Copyright (C) 2005-2026 G Chaillou Domingo, D Aunay, M Henrion, G Ballin
51  
52 This program is free software; you can redistribute it and/or modify it
53 under the terms of the Artistic License 2.0.
54  
55 This program is distributed in the hope that it will be useful, but
56 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
57 or FITNESS FOR A PARTICULAR PURPOSE. See the Artistic License 2.0 for
58 more details.
59  
60 You should have received a copy of the Artistic License 2.0 with this
61 program (see the COPYING file). If not, see
62 <https://www.perlfoundation.org/artistic-license-20.html>.
63  
64  
65 =head1 SYNOPSIS
66  
67 =head2 SIMPLE USE (fixed records)
68  
69 use oEdtk::Main;
70 use strict;
71  
72 sub main() {
73 # File input and output opening
74 oe_new_job($ARGV[0], $ARGV[1]);
75  
76 # Application initialisation (user defined)
77 &initApp();
78  
79 # Reading the input line by line
80 while (my $ligne=<IN>) {
81 chomp ($ligne);
82 # testing if $line matches pre declared records
83 if (oe_process_ref_rec(0, 3, $ligne)) {
84 } else {
85 # If not, record is ignored
86 warn "INFO IGNORE REC. line $.\n";
87 }
88 }
89  
90 # Closing input and output file
91 oe_compo_link($ARGV[0], $ARGV[1]);
92 return 1;
93 }
94  
95 sub initApp() {
96 # EXAMPLE : DECLARATION OF RECORD KEYED '016'
97 # structure of record '016' for spliting/extraction
98 # (could be delayed in 'pre_process' procedure)
99 oe_rec_motif("016", "A67 A20 A*");
100  
101 # LaTeX output declaration (only if necessary)
102 oe_rec_output("016", "<SK>%s<#DATE=%s><SK>%s");
103 return 1;
104 }
105  
106 =head2 EXAMPLE 2 (fixed records)
107  
108 use oEdtk::Main;
109 use strict;
110  
111 sub main() {
112 # File input and output opening
113 oe_new_job($ARGV[0], $ARGV[1]);
114  
115 # Application initialisation (user defined)
116 &initApp();
117  
118 # Reading the input line by line
119 while (my $ligne=<IN>) {
120 chomp ($ligne);
121 # Testing if $line match pre declared records
122 if (oe_process_ref_rec(0, 3, $ligne)){
123 } else {
124 # If not, record is ignored
125 warn "INFO IGNORE REC. line $.\n";
126 }
127 }
128  
129 # Closing input and output file
130 oe_compo_link($ARGV[0], $ARGV[1]);
131 return 1;
132 }
133  
134 sub initApp() {
135 # EXAMPLE : DECLARATION OF RECORD KEYED '016'
136 # process '&initDoc' done when record '016' is found,
137 # before to proceed the record
138 # (mandatory only if no oe_rec_motif declared)
139 oe_rec_pre_process("016", \&initDoc);
140  
141 # structure of record '016' for spliting/extraction
142 # (could be delayed in 'pre_process' procedure)
143 oe_rec_motif("016", "A67 A20 A*");
144  
145 # process '&format_date' after record is read
146 # (only if necessary)
147 oe_rec_process("016", \&format_date);
148  
149 # LaTeX output declaration (only if necessary)
150 oe_rec_output("016", "<SK>%s<#DATE=%s><SK>%s");
151  
152 # process after building the output
153 # (only if necessary)
154 recEdtk_post_process("016", \&vars_prepared_for_next_Rec);
155 return 1;
156 }
157  
158 =head1 CONVENTIONS
159  
160 Scripts are developped in functional mode. We try to use the Perl conventions,
161 we are listenning all your recommandations to make it better.
162  
163 When a sub or a function comes from the user script it's written like this :
164  
165 &function_from_the_script();
166  
167 Functions or 'methods' from perl modules are written like this :
168  
169 oe_rec_motif("016", "A67 A20 A*");
170  
171 =head1 INTERFACE
172  
173 =head2 oe_new_job
174  
175 oe_new_job( input_file, output_file, [single_job_id] )
176  
177 This function opens and shares the main filehandles IN and OUT. The parameter
178 'single_job_id' is optional. It is used to send the job id to the document
179 builder application.
180  
181 =head2 oe_compo_link
182  
183 oe_compo_link( input_file, output_file )
184  
185 This function closes the main filehandles IN and OUT. Filenames in parameters
186 are used for information, but they are mandatory.
187  
188 =head2 oe_process_ref_rec
189  
190 oe_process_ref_rec( offset_Key, key_Length, Record_Line, [offset_of_Rec, Record_length] )
191  
192 This function process the record line referenced in parameters as described with
193 'recEdtk_' tools (see below). It's made for fixed size records.
194  
195 Mandatory parameters:
196  
197 =over 4
198  
199 =item *
200  
201 'offset_key' is the starting point position of the record key
202  
203 =item *
204  
205 'key_Length' is the the length of the record key you are looking for
206  
207 =item *
208  
209 'Record_Line' is a reference to the record line you are working on
210 (C<oe_process_ref_rec> uses the reference of the line)
211  
212 =back
213  
214 Optional parameters:
215  
216 =over 4
217  
218 =item *
219  
220 'offset_of_Rec' is the starting point of the record from the beginning of
221 the line (if you want to cut down the begging of the line)
222  
223 =item *
224  
225 'Record_length' is the lenght of the record from the starting point of the record
226  
227 =back
228  
229 The C<oe_process_ref_rec> function works by ordered key size, from the left to the
230 right. You should use it by working first with the biggest record to the
231 smallest one.
232  
233 Examples :
234  
235 record 'abc' : abcvalue_1 value_2 value_3
236 record 'zzza' : zzza**value_1 value_2 value_3
237 record 'ywba' : ywba**value_AAAAAAAAA value_B
238 record '016' : ***016-value_A1 value_B2 value_C3
239 record '600' : ***600-value_A4 value_B5 value_C6
240  
241 record definitions (in fact, the order is not important here) :
242 oe_rec_motif ("zzza","A4 A2 A8 A8 A7 A*");
243 oe_rec_motif ("ywba","A4 A2 A16 A7 A*");
244 oe_rec_motif ("abc", "A3 A8 A8 A7 A*");
245 oe_rec_motif ("016", "A3 A3 A1 A9 A9 A7 A*");
246 oe_rec_motif ("600", "A3 A1 A9 A9 A7 A*");
247  
248 you will process from left to right, from bigest to smallest :
249 if (oe_process_ref_rec(0, 4, $ligne)) {
250 # this will process both records 'zzza' and 'ywba' .
251  
252 } elsif (oe_process_ref_rec(0, 3, $ligne, 3)) {
253 # this will process records 'abc'
254 # (and cut away first 3 caracters of the record line).
255  
256 } elsif (oe_process_ref_rec(3, 3, $ligne, 6)) {
257 # this will process both records '016' and '600'
258 # (and cut away first 6 caracters of the record line).
259  
260 } else {
261 # if not, record is ignored
262 warn "INFO IGNORE REC. line $.\n";
263 }
264  
265 The C<oe_process_ref_rec> function returns 1 when it recognizes and processes the
266 record (including the output if C<oe_rec_output> is defined). Values extracted
267 from the record are split into the C<@DATATAB> oEdtk global array.
268 C<oe_process_ref_rec> returns 0 when it could not recognize the record.
269  
270 The C<oe_process_ref_rec> function makes these differents steps :
271  
272 =over 4
273  
274 =item 1.
275  
276 look if there is a record key corresponding
277  
278 =item 2.
279  
280 run the pre-process function if defined (see C<oe_rec_pre_process>)
281  
282 =item 3.
283  
284 unpack the record according to oe_rec_motif definition into C<@DATATAB>
285  
286 =item 4.
287  
288 run the process function if defined (see L</oe_rec_process>)
289  
290 =item 5.
291  
292 build output if oe_rec_output is defined
293  
294 =item 6.
295  
296 run the post-process function if defined (see L</recEdtk_post_process>)
297  
298 =back
299  
300 =head2 oe_rec_motif
301  
302 oe_rec_motif( Record_Key_ID, Record_Template )
303  
304 Create a record with the 'Record_Key_ID' identifier or type. This key
305 identifier should be in the record. This function defines the 'Record_Template'
306 used to expand / extract the record (see L<unpack|perlfunc/unpack> for template
307 description). This function is mandatory, but cannot be defined after
308 C<oe_rec_pre_process>.
309  
310 Example :
311  
312 oe_rec_motif("016", "A2 A10 A15 A10 A15 A*");
313  
314 It is recommended to add 'A*' at the end of the template to cut away any
315 unexpected data that will remain at the end of the record.
316  
317 =head2 oe_rec_process
318  
319 oe_rec_process( Record_Key_ID, \&user_sub_reference )
320  
321 This function links the record 'Record_Key_ID' with a process sub. This sub is
322 called after the extraction / expanding of the record. When this process is
323 defined, it's called before the building of the output (if defined, see
324 L</oe_rec_output>). You can access the expanded data by reading/writing global
325 tab C<@DATATAB>. This function is optional.
326  
327 =head2 oe_rec_output
328  
329 oe_rec_output( Record_Key_ID, Output_Template )
330  
331 This function defines an 'Output_Template' for the record 'Record_Key_ID'. This
332 template is used to build the output file (see L<sprintf|perlfunc/sprintf> for
333 the template description). The output is built after the record process
334 (L</oe_rec_process> if this one is defined). You can access the expanded data
335 by reading/writing global tab C<@DATATAB>. This function is optional. If no
336 C<oe_rec_output> is defined for the 'Record_Key_ID', the record would be erased
337 at the next record process.
338  
339 Example :
340  
341 oe_rec_output("016", "<SK>%s<#DATE=%s><SK>%s");
342  
343 =head2 recEdtk_post_process
344  
345 recEdtk_post_process( Record_Key_ID, \&user_sub_reference )
346  
347 This function links the record 'Record_Key_ID' with a process sub. This sub is
348 called after the building of the output. When this process is defined, it's
349 called before the next record read. You can access the expanded data by
350 reading/writing global tab C<@DATATAB>. This function is optional.
351  
352 =head2 recEdtk_erase
353  
354 recEdtk_erase( Record_Key_ID )
355  
356 This function will erase all the descriptions made for the record
357 'Record_Key_ID'. This is useful when you want to ignore a record (this will
358 cause a message 'Record Unknown' as if it has never been declared before) or
359 when you want to redefine a record during the process.
360  
361 =head2 recEdtk_redefine
362  
363 recEdtk_redefine( Record_Key_ID, Record_Template )
364  
365 This function will erase (as above) AND redefine the record 'Record_Key_ID' and
366 its template 'Record_Template'. With this function, you define the necessary to
367 start processing the record. It's the less you can do.
368  
369 Example :
370  
371 recEdtk_redefine("016", "A2 A10 A15 A10 A15 A*");
372  
373 =head1 AUTHORS
374  
375 oEdtk by D Aunay, GJ Chaillou Domingo, M Henrion, G Ballin.
376  
377 This pod text by GJ Chaillou Domingo, M Henrion and others.
378 Perl by Larry Wall and the C<perl5-porters>.
379  
380 =head1 COPYRIGHT
381  
382 The oEdtk module is Copyright (c) .
383 All rights reserved.
384  
385 You may distribute under the terms of the Artistic License 2.0,
386 as specified in the COPYING file.
387  
388 =head1 SUPPORT / WARRANTY
389  
390 The oEdtk is free Open Source software. IT COMES WITHOUT WARRANTY OF ANY KIND.