--- nfo/perl/libs/Data/Rap/Engine.pm 2003/02/21 01:46:17 1.3 +++ nfo/perl/libs/Data/Rap/Engine.pm 2003/03/28 07:02:56 1.7 @@ -1,7 +1,20 @@ ## ---------------------------------------------------------------------- -## $Id: Engine.pm,v 1.3 2003/02/21 01:46:17 joko Exp $ +## $Id: Engine.pm,v 1.7 2003/03/28 07:02:56 joko Exp $ ## ---------------------------------------------------------------------- ## $Log: Engine.pm,v $ +## Revision 1.7 2003/03/28 07:02:56 joko +## modified structure around '$wrapper_program' +## +## Revision 1.6 2003/03/27 15:31:05 joko +## fixes to modules regarding new namespace(s) below Data::Mungle::* +## +## Revision 1.5 2003/03/27 15:03:03 joko +## enhanced 'sub run_executable' +## +## Revision 1.4 2003/02/22 16:51:21 joko +## + enhanced run_executable +## modified logging output +## ## Revision 1.3 2003/02/21 01:46:17 joko ## renamed core function ## @@ -27,8 +40,8 @@ use Iterate; use shortcuts qw( run_cmd ); -use Data::Code::Ref qw( ref_slot ); -use Data::Transform::Deep qw( expand ); +use Data::Mungle::Code::Ref qw( ref_slot ); +use Data::Mungle::Transform::Deep qw( expand ); sub performTarget { @@ -41,7 +54,12 @@ my $self = shift; my $targetname = shift; - $self->log("Performing Target '$targetname'.", 'notice'); + my $header = ("- " x 12) . " " . $targetname . " " . ("- " x 6); + + #$self->log("- " x 35, 'notice'); + #$self->log("Performing Target '$targetname'.", 'notice'); + + $self->log($header, 'notice'); #exit; @@ -102,7 +120,7 @@ my $command = shift; if (!$command) { - $self->log("Command was empty!", 'warning'); + $self->log("Command was empty!", 'debug'); return; } @@ -287,16 +305,37 @@ my $program = $opts->{executable}; delete $opts->{executable}; + # determine execution method + my $wrapper_program = ''; + + # check if program is a namespace-string (contains '::') - use 'do' in this case! + if ($program =~ /::/) { + #$wrapper_program = 'rap.pl'; + $wrapper_program = $0; + } + + # prepare arguments my @buf; foreach (keys %$opts) { my $value = $opts->{$_}; + if (m/^_/) { + if ($_ eq '_switches') { + my @switches = split(/,\s|,/, $value); + foreach my $switch (@switches) { + push @buf, '--' . $switch; + } + } + next; + } + if ($value =~ /\s/) { $value = "\"$value\""; } push @buf, "--$_=$value"; } - - my $cmd = $program . ' ' . join(' ', @buf); + + # build {program} & {arguments} + my $cmd = ($wrapper_program ? $wrapper_program . ' ' : '') . $program . ' ' . join(' ', @buf); # trace #print "command: $cmd", "\n"; @@ -309,10 +348,24 @@ $ENV{PERL5LIB} = $INC[0]; #print Dumper(%ENV); - run_cmd($cmd); + + #print "command: '$cmd'", "\n"; + + # V1 - basic + #run_cmd($cmd); + + # V1.b - enhanced: variable local method + my $evalstr = "run_cmd('$cmd', 'Some task...', { async => 1 });"; + eval($evalstr); + #my $res = do "$cmd"; + #print $res, "\n" if $res; + + #$self->log("run_executable: $evalstr", 'info'); + $self->raiseException("run_executable: $evalstr\n$@") if $@; + # V2: via IPC::Run # .... (TODO) - + }