/[cvs]/nfo/perl/libs/Data/Rap/Engine.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Rap/Engine.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by joko, Fri Feb 21 01:46:17 2003 UTC revision 1.6 by joko, Thu Mar 27 15:31:05 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## ----------------------------------------------------------------------  ## ----------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.6  2003/03/27 15:31:05  joko
6    ##  fixes to modules regarding new namespace(s) below Data::Mungle::*
7    ##
8    ##  Revision 1.5  2003/03/27 15:03:03  joko
9    ##  enhanced 'sub run_executable'
10    ##
11    ##  Revision 1.4  2003/02/22 16:51:21  joko
12    ##  + enhanced run_executable
13    ##  modified logging output
14    ##
15  ##  Revision 1.3  2003/02/21 01:46:17  joko  ##  Revision 1.3  2003/02/21 01:46:17  joko
16  ##  renamed core function  ##  renamed core function
17  ##  ##
# Line 27  use Hash::Merge qw( merge ); Line 37  use Hash::Merge qw( merge );
37  use Iterate;  use Iterate;
38    
39  use shortcuts qw( run_cmd );  use shortcuts qw( run_cmd );
40  use Data::Code::Ref qw( ref_slot );  use Data::Mungle::Code::Ref qw( ref_slot );
41  use Data::Transform::Deep qw( expand );  use Data::Mungle::Transform::Deep qw( expand );
42    
43    
44  sub performTarget {  sub performTarget {
# Line 41  sub perform_target { Line 51  sub perform_target {
51    my $self = shift;    my $self = shift;
52    my $targetname = shift;    my $targetname = shift;
53    
54    $self->log("Performing Target '$targetname'.", 'notice');    my $header = ("- " x 12) . "   " . $targetname . "   " . ("- " x 6);
55      
56      #$self->log("- " x 35, 'notice');
57      #$self->log("Performing Target '$targetname'.", 'notice');
58    
59      $self->log($header, 'notice');
60    
61    #exit;    #exit;
62    
# Line 102  sub perform_command { Line 117  sub perform_command {
117    my $command = shift;    my $command = shift;
118    
119    if (!$command) {    if (!$command) {
120      $self->log("Command was empty!", 'warning');      $self->log("Command was empty!", 'debug');
121      return;      return;
122    }    }
123    
# Line 287  sub run_executable { Line 302  sub run_executable {
302      my $program = $opts->{executable};      my $program = $opts->{executable};
303      delete $opts->{executable};      delete $opts->{executable};
304    
305        # determine execution method
306        my $method = 'run_cmd';
307        my $wrapper_program = '';
308        
309        # check if program is a namespace-string (contains '::') - use 'do' in this case!
310        if ($program =~ /::/) {
311        #if ($program =~ s/::/\\/g) {
312          #$program = '.\\' . $program;
313          #$method = 'require';
314          #do "$program";
315          #return;
316          #$method = 'rap.';
317          
318          $wrapper_program = 'rap.pl';
319          
320        }
321    
322        # prepare arguments
323      my @buf;      my @buf;
324      foreach (keys %$opts) {      foreach (keys %$opts) {
325        my $value = $opts->{$_};        my $value = $opts->{$_};
326          if (m/^_/) {
327            if ($_ eq '_switches') {
328              my @switches = split(/,\s|,/, $value);
329              foreach my $switch (@switches) {
330                push @buf, '--' . $switch;
331              }
332            }
333            next;
334          }
335          
336        if ($value =~ /\s/) {        if ($value =~ /\s/) {
337          $value = "\"$value\"";          $value = "\"$value\"";
338        }        }
339        push @buf, "--$_=$value";        push @buf, "--$_=$value";
340      }      }
341      
342      my $cmd = $program . ' ' . join(' ', @buf);      # build {program} & {arguments}  
343        my $cmd = join(' ', $wrapper_program, $program) . ' ' . join(' ', @buf);
344            
345      # trace      # trace
346        #print "command: $cmd", "\n";        #print "command: $cmd", "\n";
# Line 309  sub run_executable { Line 353  sub run_executable {
353        $ENV{PERL5LIB} = $INC[0];        $ENV{PERL5LIB} = $INC[0];
354                
355        #print Dumper(%ENV);        #print Dumper(%ENV);
356        run_cmd($cmd);        
357          print "command: '$cmd'", "\n";
358    
359          # V1 - basic
360          #run_cmd($cmd);
361    
362          # V1.b - enhanced: variable local method
363          my $evalstr = "$method('$cmd');";
364          eval($evalstr);
365          #my $res = do "$cmd";
366          #print $res, "\n" if $res;
367    
368          #$self->log("run_executable: $evalstr", 'info');
369          $self->raiseException("run_executable: $evalstr\n$@") if $@;
370    
371        # V2: via IPC::Run        # V2: via IPC::Run
372        # ....  (TODO)        # ....  (TODO)
373            

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.6

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed