lib/App/SeismicUnixGui/developer/code/sunix/prog_doc2pm.pm untested

filter: Statementstmt 0.0% 0 / 151 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 16 Podpod 0.0% 0 / 13 totaltotal 0.0% 0 / 221 CC 17 SCAR 19.9
CC
17
Cov
0%
_get_list_aref
12.0
get_list_aref
12.0
get_program_aref
12.0
CRAP 7.3
1 package App::SeismicUnixGui::developer::code::sunix::prog_doc2pm;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PROGRAM NAME: prog_doc2pm.pm
8  
9 AUTHOR: Juan Lorenzo
10 DATE: Nov 14 2018
11 DESCRIPTION:
12 package of to access programs
13 for which a module is to be made
14
15 Version: 1.0.0
16  
17 =head2 USE
18  
19 =head3 NOTES
20  
21 =head4 Examples
22 my $selected_program_name = 'sugetgthr';
23 =head3 SEISMIC UNIX NOTES
24  
25 =head2 CHANGES and their DATES
26  
27 =cut
28  
29 use Moose;
30 our $VERSION = '0.0.1';
31 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
32 use Cwd;
33  
34 my $get = L_SU_global_constants->new();
35  
36 my $var = $get->var();
37 my $empty_string = $var->{_empty_string};
38 my $global_libs = $get->global_libs();
39 my $SeismicUnixGui = $var->{_SeismicUnixGui};
40  
41 my $developer_sunix_categories_aref = $get->developer_sunix_categories_aref();
42 my @developer_sunix_categories = @$developer_sunix_categories_aref;
43  
44 my $prog_doc2pm = {
45 _list_length => '',
46 _list_names_aref => '',
47 _group_directory => '',
48 _path => '',
49 };
50  
51 =head2 declaration of local variables
52  
53 =cut
54  
55 my ( @file_in, @pm_file_out, @package_name, @program_name );
56 my (@config_file_out);
57 my ( @spec_file_out, $group_no );
58 my ( @inbound, @path_out, $path );
59  
60 =head2 sub _get_list_aref
61 List of file names from within a directory
62
63 =cut
64  
65 sub _get_list_aref {
66  
67 my ($self) = @_;
68  
69 if ( $prog_doc2pm->{_group_directory} ne $empty_string ) {
70  
71 my $list_aref;
72 my $path_in = _get_path_in();
73 my $directory = $prog_doc2pm->{_group_directory};
74 $prog_doc2pm->{_path} = $path_in . '/Stripped/' . $directory;
75 my $path = $prog_doc2pm->{_path};
76  
77 # print("prog_doc2pm,_get_list_aref, PATH:$prog_doc2pm->{_path}\n");
78  
79 opendir my $dh, $path or die "Could not open '$path' for reading: $!\n";
80  
81 my @file_name;
82 my $thing;
83 my @name;
84  
85 while ( defined( $thing = readdir $dh ) ) {
86  
87 $thing =~ s/\///;
88  
89 # print("prog_doc2pm,count=$count; file_name=$thing\___\n");
90  
91 if ( not( $thing =~ /^\.\.?$/ ) ) {
92  
93 (@name) = split( /\./, $thing );
94 push @file_name, $name[0];
95  
96 # print("prog_doc2pm,file_name=$name[0]\___\n");
97  
98 } else { # skip . and ..
99  
100 # print("prog_doc2pm, skipping\___\n");
101 }
102  
103 $list_aref = \@file_name;
104 }
105 closedir $dh;
106  
107 # print("prog_doc2pm,_get_list_aref,file_names=@file_name\n");
108 return ($list_aref);
109  
110 } else {
111 print("prog_doc2pm, _get_list_aref, missing group no,\n");
112 return ();
113 }
114  
115 }
116  
117 =head2 sub _get_path_in
118  
119  
120 =cut
121  
122 sub _get_path_in {
123  
124 my ($self) = @_;
125  
126 if ( $prog_doc2pm->{_group_directory} ne $empty_string ) {
127  
128 my $local_dir= getcwd();
129 my $up3dir = '/../../../';
130 my $path_in = $local_dir.$up3dir.'developer';
131  
132 # print("prog_doc2pm,_get_path_in = $path_in\n");
133 return ($path_in);
134  
135 } else {
136 print("prog_doc2pm, _get_path_in, missing directory,\n");
137 return ();
138 }
139 }
140  
141 =head2 sub get_group_directory
142  
143  
144 =cut
145  
146 sub get_group_directory {
147  
148 my ($self) = @_;
149  
150 if ( $prog_doc2pm->{_group_directory} ne $empty_string ) {
151  
152 $prog_doc2pm->{_group_directory} = $developer_sunix_categories[$group_no];
153  
154 #print("prog_doc2pm, get_group_directory,$prog_doc2pm->{_group_directory}\n");
155  
156 } else {
157 print("prog_doc2pm, get_group_directory, missing group no,\n");
158 }
159 }
160  
161 =head2 sub get_list_aref
162  
163  
164 =cut
165  
166 sub get_list_aref {
167  
168 my ($self) = @_;
169  
170 if ( $prog_doc2pm->{_group_directory} ne $empty_string ) {
171  
172 my $list_aref;
173 my $path_in = _get_path_in();
174  
175 my $directory = $prog_doc2pm->{_group_directory};
176 $prog_doc2pm->{_path} = $path_in . '/Stripped/' . $directory;
177 my $path = $prog_doc2pm->{_path};
178  
179 # print("prog_doc2pm,get_list_aref, PATH:$prog_doc2pm->{_path}\n");
180  
181 opendir my $dh, $path or die "Could not open '$path' for reading: $!\n";
182  
183 my @file_name;
184 my @name;
185 my $thing;
186  
187 while ( defined( $thing = readdir $dh ) ) {
188  
189 $thing =~ s/\///;
190  
191 if ( not( $thing =~ /^\.\.?$/ ) ) {
192  
193 push @file_name, $thing;
194  
195 # print("prog_doc2pm,ile_name=$thing\___\n");
196  
197 } else { # skip . and ..
198  
199 # print("prog_doc2pm, skipping\___\n");
200 }
201 $list_aref = \@file_name;
202 }
203 closedir $dh;
204  
205 # print("prog_doc2pm,get_list_aref,file_names=@file_name\n");
206 return ($list_aref);
207  
208 } else {
209 print("prog_doc2pm, get_list_aref, missing group no,\n");
210 return ();
211 }
212 }
213  
214 =head2 sub get_list_length
215  
216 =cut
217  
218 sub get_list_length {
219  
220 my ($self) = @_;
221  
222 if ( $prog_doc2pm->{_group_directory} ne $empty_string ) {
223  
224 my $length = ( scalar @{ _get_list_aref() } );
225  
226 # print("prog_doc2pm,get_list_length,length= $length \n");
227 return ($length);
228  
229 } else {
230 print("prog_doc2pm, get_list_length, missing group no,\n");
231 return ();
232 }
233 }
234  
235 =head2 sub get_path_in
236  
237  
238 =cut
239  
240 sub get_path_in {
241  
242 my ($self) = @_;
243  
244 if ( $prog_doc2pm->{_group_directory} ne $empty_string ) {
245  
246 my $dir = $prog_doc2pm->{_group_directory};
247  
248 my $local_dir= getcwd();
249 my $up3dir = '/../../../';
250 my $path_in = $local_dir.$up3dir.'developer/Stripped'. '/' . $dir;
251  
252 # print("prog_doc2pm,get_path_in = $path_in\n");
253 return ($path_in);
254  
255 } else {
256 print("prog_doc2pm, get_,path_in missing directory,\n");
257 return ();
258 }
259 }
260  
261 =head2 sub get_path_out4configs
262  
263  
264 =cut
265  
266 sub get_path_out4configs {
267  
268 my ($self) = @_;
269  
270 if ( $prog_doc2pm->{_group_directory} ne $empty_string ) {
271  
272 my $dir = $prog_doc2pm->{_group_directory};
273  
274 my $PATH_OUT = $global_libs->{_configs} . '/' . $dir;
275  
276 # print("prog_doc2pm,get_path_out4configs = $PATH_OUT\n");
277 return ($PATH_OUT);
278  
279 } else {
280 print("prog_doc2pm, get_path_out4configs missing directory,\n");
281 return ();
282 }
283 }
284  
285 =head2 sub get_path_out
286  
287  
288 =cut
289  
290 sub get_path_out4developer {
291  
292 my ($self) = @_;
293  
294 if ( $prog_doc2pm->{_group_directory} ne $empty_string ) {
295  
296 my $dir = $prog_doc2pm->{_group_directory};
297  
298 my $PATH_OUT = $global_libs->{_developer} . '/' . $dir;
299  
300 # print("prog_doc2pm,get_path_out4developer = $PATH_OUT\n");
301 return ($PATH_OUT);
302  
303 } else {
304 print("prog_doc2pm, get_,path_out missing directory,\n");
305 return ();
306 }
307 }
308  
309 =head2 sub get_path_out4global_constants
310  
311  
312 =cut
313  
314 sub get_path_out4global_constants {
315  
316 my ($self) = @_;
317  
318 if ( $prog_doc2pm->{_group_directory} ne $empty_string ) {
319  
320 # my $path = '/usr/local/pl/L_SU/misc';
321  
322 my $PATH_OUT = $global_libs->{_misc};
323  
324 # print("prog_doc2pm, get_path_out4global_constants= $PATH_OUT\n");
325 return ($PATH_OUT);
326  
327 } else {
328 print("prog_doc2pm, get_path_out4global_constants missing directory,\n");
329 return ();
330 }
331  
332 }
333  
334 =head2 sub get_path_out4specs
335  
336  
337 =cut
338  
339 sub get_path_out4specs {
340  
341 my ($self) = @_;
342  
343 if ( $prog_doc2pm->{_group_directory} ne $empty_string ) {
344  
345 # my $path = '/usr/local/pl/L_SU/specs';
346 my $dir = $prog_doc2pm->{_group_directory};
347  
348 my $PATH_OUT = $global_libs->{_specs} . '/' . $dir;
349  
350 # print("prog_doc2pm, get_path_out4specs= $PATH_OUT\n");
351 return ($PATH_OUT);
352  
353 } else {
354 print("prog_doc2pm, get_path_out4specs missing directory,\n");
355 return ();
356 }
357  
358 }
359  
360 =head2 sub get_path_out4sunix
361  
362  
363 =cut
364  
365 sub get_path_out4sunix {
366  
367 my ($self) = @_;
368  
369 if ( $prog_doc2pm->{_group_directory} ne $empty_string ) {
370  
371 my $dir = $prog_doc2pm->{_group_directory};
372  
373 my $PATH_OUT = $global_libs->{_sunix} . '/' . $dir;
374  
375 print("prog_doc2pm,get_path_out4sunix = $PATH_OUT\n");
376 return ($PATH_OUT);
377  
378 } else {
379 print("prog_doc2pm, get_path_out4sunix missing directory,\n");
380 return ();
381 }
382 }
383  
384 =head2 sub get_program_aref
385  
386 =cut
387  
388 sub get_program_aref {
389  
390 my ($self) = @_;
391  
392 if ( $prog_doc2pm->{_group_directory} ne $empty_string ) {
393  
394 my $list_aref;
395 my $path_in = _get_path_in();
396 my $directory = $prog_doc2pm->{_group_directory};
397 $prog_doc2pm->{_path} = $path_in . '/Stripped/' . $directory;
398 my $path = $prog_doc2pm->{_path};
399  
400 # print("prog_doc2pm,get_program_aref, PATH:$prog_doc2pm->{_path}\n");
401  
402 opendir my $dh, $path or die "Could not open '$path' for reading: $!\n";
403  
404 # print("prog_doc2pm,_get_program_aref, DIR=$path\n");
405 my @file_name;
406 my $thing;
407 my @name;
408  
409 while ( defined( $thing = readdir $dh ) ) {
410  
411 $thing =~ s/\///;
412  
413 if ( not( $thing =~ /^\.\.?$/ ) ) {
414  
415 (@name) = split( /\./, $thing );
416 push @file_name, $name[0];
417  
418 # print("prog_doc2pm,file_name=$name[0] \___\n");
419  
420 } else { # skip . and ..
421  
422 # print("prog_doc2pm, skipping $thing\n");
423 }
424  
425 $list_aref = \@file_name;
426  
427 } # end while
428 closedir $dh;
429  
430 # print("prog_doc2pm,get_program_aref,file_names=@file_name\n");
431 return ($list_aref);
432  
433 } else {
434 print("prog_doc2pm, get_program_aref, missing group no,\n");
435 return ();
436 }
437  
438 }
439  
440 =head2 sub set_group_directory
441  
442  
443 =cut
444  
445 sub set_group_directory {
446  
447 my ( $self, $group_no ) = @_;
448  
449 if ( $group_no ne $empty_string ) {
450  
451 $prog_doc2pm->{_group_directory} = $developer_sunix_categories[$group_no];
452  
453 # print("prog_doc2pm, set_group_directory,$prog_doc2pm->{_group_directory}\n");
454  
455 } else {
456 print("prog_doc2pm, set_group_directory, missing group no,\n");
457 }
458 }
459  
460 1;