520520 $self -> app_log-> fatal($rule_example );
521521}
522522
523- =head3 carry_directives
524-
525- At the beginning of each rule the previous outdir should be the new indir, and the previous OUTPUT should be the new INPUT
526-
527- Stash should be carried over
528-
529- Outdir should be global_attr->outdir/rule_name
530-
531- =cut
532-
533- sub carry_directives {
534- my $self = shift ;
535-
536- $self -> local_attr-> outdir(
537- $self -> global_attr-> outdir . ' /' . $self -> rule_name );
538-
539- return unless $self -> has_p_rule_name;
540-
541- $self -> local_attr-> indir( dclone( $self -> p_local_attr-> outdir ) );
542-
543- if ( $self -> p_local_attr-> has_OUTPUT ) {
544- if ( ref ( $self -> p_local_attr-> OUTPUT ) ) {
545- $self -> local_attr-> INPUT( dclone( $self -> p_local_attr-> OUTPUT ) );
546- }
547- else {
548- $self -> local_attr-> INPUT( $self -> p_local_attr-> OUTPUT );
549- }
550- }
551-
552- $self -> local_attr-> stash( dclone( $self -> p_local_attr-> stash ) );
553- }
554523
555524=head3 template_process
556525
@@ -571,6 +540,7 @@ sub template_process {
571540
572541 my $dummy_sample = $self -> dummy_sample;
573542 my $dummy_texts = $self -> check_iterables( $dummy_sample , [] );
543+
574544 foreach my $sample ( $self -> all_samples ) {
575545 foreach my $text ( @{$dummy_texts } ) {
576546 my $new_text = $text ;
@@ -647,7 +617,6 @@ sub check_iterables {
647617 push ( @$texts , $new_text );
648618 }
649619 }
650- # #
651620
652621 return $texts ;
653622}
@@ -667,6 +636,35 @@ sub in_template_process {
667636 return $texts ;
668637}
669638
639+ sub walk_attr {
640+ my $self = shift ;
641+
642+ my $attr = dclone( $self -> local_attr );
643+ $self -> check_indir_outdir($attr );
644+
645+ $DB::single = 2;
646+
647+ $attr -> walk_process_data( $self -> rule_keys );
648+
649+ return $attr ;
650+ }
651+
652+ sub eval_process {
653+ my $self = shift ;
654+
655+ my $attr = $self -> walk_attr;
656+ $attr -> sample( $self -> sample ) if $self -> has_sample;
657+
658+ my $process = $self -> local_rule-> { $self -> rule_name }-> {process };
659+ my $text = $attr -> interpol_directive($process );
660+ $text = clean_text($text );
661+
662+ $self -> walk_FILES($attr );
663+ $self -> clear_files;
664+
665+ return $text ;
666+ }
667+
670668sub get_global_keys {
671669 my $self = shift ;
672670 my @global_keys = ();
@@ -704,16 +702,21 @@ sub get_keys {
704702}
705703
706704# #TODO Clean this up and merge with the other walk_iterables
705+ # #TODO Write more tests
707706sub walk_indir_outdir {
708707 my $self = shift ;
709708 my $use_iters = shift ;
710709
710+ # #TODO This is redundant...
711711 my $attr = dclone( $self -> local_attr );
712- $self -> check_indir_outdir($attr );
713-
714712 my $dummy_sample = $self -> dummy_sample;
715713 $attr -> sample($dummy_sample );
716- my $text = $attr -> interpol_directive( $attr -> outdir );
714+
715+ if ( $attr -> outdir =~ m /\{\$ / ) {
716+ $attr -> walk_process_data( $self -> rule_keys );
717+ }
718+
719+ my $text = $attr -> interpol_directive( $self -> local_attr-> outdir );
717720
718721 if ( !$use_iters ) {
719722 foreach my $sample ( $attr -> all_samples ) {
@@ -747,51 +750,17 @@ sub decide_create_outdir {
747750 my $attr = shift ;
748751 my $dir = shift ;
749752
750- if ( $attr -> create_outdir ) {
753+ return unless $attr -> create_outdir;
754+ return unless $dir ;
751755
752- try {
753- $dir -> mkpath;
754- }
755- catch {
756- $self -> app_log-> fatal( " We were not able to make the directory.\n\t "
757- . $attr -> outdir
758- . " \n\t Error: $! " );
759- };
756+ try {
757+ $dir -> mkpath;
760758 }
761- }
762-
763- sub walk_attr {
764- my $self = shift ;
765-
766- my $attr = dclone( $self -> local_attr );
767- $self -> check_indir_outdir($attr );
768-
769- $DB::single = 2;
770-
771- $attr -> walk_process_data( $self -> rule_keys );
772-
773- return $attr ;
774- }
775-
776- sub make_outdirs {
777- my $self = shift ;
778-
779- }
780-
781- sub eval_process {
782- my $self = shift ;
783-
784- my $attr = $self -> walk_attr;
785- $attr -> sample( $self -> sample ) if $self -> has_sample;
786-
787- my $process = $self -> local_rule-> { $self -> rule_name }-> {process };
788- my $text = $attr -> interpol_directive($process );
789- $text = clean_text($text );
790-
791- $self -> walk_FILES($attr );
792- $self -> clear_files;
793-
794- return $text ;
759+ catch {
760+ $self -> app_log-> fatal( " We were not able to make the directory.\n\t "
761+ . $attr -> outdir
762+ . " \n\t Error: $! " );
763+ };
795764}
796765
797766sub clean_text {
@@ -856,6 +825,8 @@ sub print_rule {
856825 return $print_rule ;
857826}
858827
828+ # #This is not necessary without the use_timestamps
829+ # #But I will leave it in as a placeholder
859830sub print_within_rule {
860831 my $self = shift ;
861832
@@ -895,6 +866,7 @@ sub check_indir_outdir {
895866
896867 # If indir/outdir is specified in the local config
897868 # then we don't evaluate it
869+
898870 foreach my $dir ( ( ' indir' , ' outdir' ) ) {
899871 if ( grep /$dir /, @{ $self -> local_rule_keys } ) {
900872 next ;
@@ -919,4 +891,36 @@ sub check_indir_outdir {
919891
920892}
921893
894+ =head3 carry_directives
895+
896+ At the beginning of each rule the previous outdir should be the new indir, and the previous OUTPUT should be the new INPUT
897+
898+ Stash should be carried over
899+
900+ Outdir should be global_attr->outdir/rule_name
901+
902+ =cut
903+
904+ sub carry_directives {
905+ my $self = shift ;
906+
907+ $self -> local_attr-> outdir(
908+ $self -> global_attr-> outdir . ' /' . $self -> rule_name );
909+
910+ return unless $self -> has_p_rule_name;
911+
912+ $self -> local_attr-> indir( dclone( $self -> p_local_attr-> outdir ) );
913+
914+ if ( $self -> p_local_attr-> has_OUTPUT ) {
915+ if ( ref ( $self -> p_local_attr-> OUTPUT ) ) {
916+ $self -> local_attr-> INPUT( dclone( $self -> p_local_attr-> OUTPUT ) );
917+ }
918+ else {
919+ $self -> local_attr-> INPUT( $self -> p_local_attr-> OUTPUT );
920+ }
921+ }
922+
923+ $self -> local_attr-> stash( dclone( $self -> p_local_attr-> stash ) );
924+ }
925+
9229261;
0 commit comments