/[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.9 by joko, Fri Apr 4 17:23:11 2003 UTC revision 1.12 by jonen, Tue Jun 24 20:59:51 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## ----------------------------------------------------------------------  ## ----------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.12  2003/06/24 20:59:51  jonen
6    ##  added option 'detach'
7    ##
8    ##  Revision 1.11  2003/06/23 17:54:32  joko
9    ##  prepared execution of in-process perl-code via eval (not activated yet!)
10    ##
11    ##  Revision 1.10  2003/05/13 07:56:12  joko
12    ##  enhanced: *hierarchical* containers for context handling
13    ##  fixes: some pre-flight checks
14    ##  new: propagate "end-tag" event to e.g. close containers
15    ##
16  ##  Revision 1.9  2003/04/04 17:23:11  joko  ##  Revision 1.9  2003/04/04 17:23:11  joko
17  ##  minor update: debugging output  ##  minor update: debugging output
18  ##  ##
# Line 62  sub perform_target { Line 73  sub perform_target {
73    my $self = shift;    my $self = shift;
74    my $targetname = shift;    my $targetname = shift;
75    
76      # pre-flight checks
77      if (!$targetname) {
78        $self->log("Target name empty. Please try to specify (e.g.) on the command line.", 'critical');
79        return;
80      }
81    
82    my $header = ("- " x 12) . "   " . $targetname . "   " . ("- " x 6);    my $header = ("- " x 12) . "   " . $targetname . "   " . ("- " x 6);
83        
84    # V1    # V1
# Line 85  sub perform_target { Line 102  sub perform_target {
102            
103    $self->perform_dependencies($target);    $self->perform_dependencies($target);
104    $self->perform_details($target);    $self->perform_details($target);
105      
106      return 1;
107    
108  }  }
109    
# Line 117  sub perform_details { Line 136  sub perform_details {
136      my $command = $entry->{name};      my $command = $entry->{name};
137      my $args = $entry->{attrib};      my $args = $entry->{attrib};
138      my $content = $entry->{content};      my $content = $entry->{content};
139      $self->perform_command($command, $args, $content);      $self->perform_command($command, $args, $content, { warn => 1 } );
140      # check recursiveness      # check recursiveness
141      if ($entry->{content} && ref $entry->{content}) {      # new condition: don't recurse if node is flagged to have inline-args (2003-04-17)
142        my $has_inline_args = ($entry->{attrib}->{_args} && $entry->{attrib}->{_args} eq 'inline');
143        if ($entry->{content} && ref $entry->{content} && !$has_inline_args) {
144        $self->perform_details($entry);        $self->perform_details($entry);
145      }      }
146        # new of 2003-05-08
147        $command ||= '';
148        $self->perform_command($command . '_end', undef, undef, { warn => 0 } );
149    }    }
150  }  }
151    
# Line 135  sub perform_command { Line 159  sub perform_command {
159    my $command = shift;    my $command = shift;
160    my $args_list = shift;    my $args_list = shift;
161    my $content = shift;    my $content = shift;
162      my $options = shift;
163    
164    if (!$command) {    if (!$command) {
165      $self->log("Command was empty!", 'debug');      $self->log("Command was empty!", 'debug');
# Line 144  sub perform_command { Line 169  sub perform_command {
169    # FIXME: make '__PACKAGE__' go one level deeper properly!    # FIXME: make '__PACKAGE__' go one level deeper properly!
170    $self->log( __PACKAGE__ . "->perform_command: " . $command, 'debug');    $self->log( __PACKAGE__ . "->perform_command: " . $command, 'debug');
171        
172      
173      # 1. make arguments from list of arguments(?)
174    
175    my $args = {};    my $args = {};
176    #print Dumper($args_list);    #print Dumper($args_list);
177    if ($args_list) {    if ($args_list) {
# Line 155  sub perform_command { Line 183  sub perform_command {
183        $args = $args_list;        $args = $args_list;
184      }      }
185    }    }
   $command = '_' . $command;  
186        
187        
188    # determine container    # 2. prepare command
189      
190      # default setting for internal rap commands
191      my $method_prefix_default = '_';
192      # setting from property database
193      my $method_prefix_setting = $self->get_property('core.method_prefix');
194      #print "setting: ", $method_prefix_setting, "\n";
195      my $prefix = $method_prefix_setting;
196      if (not defined $prefix) {
197        $prefix = $method_prefix_default;
198      }
199      $command = $prefix . $command;
200      
201      
202      # 3. determine container
203    my $container; # = $self->getInstance();    my $container; # = $self->getInstance();
204      #$container ||= $self->getInstance();
205    $container ||= $self;    $container ||= $self;
206        
207      # 4. run method
208    if ($container->can($command)) {    if ($container->can($command)) {
209      $container->$command($args, $content);      $container->$command($args, $content);
210    } else {    } else {
211      $self->log("Command '$command' not implemented.", "warning");      my $level = "debug";
212        $level = "warning" if $options->{warn};
213        $self->log("Command '$command' not implemented.", $level);
214    }    }
215        
216  }  }
# Line 229  sub set_property { Line 274  sub set_property {
274    
275    $self->log("set-name: $name");    $self->log("set-name: $name");
276    
277      #print Dumper($name, $value, '.');
278    
279    # fill property slot with given value    # fill property slot with given value
280    if ($value) {    # fix (2003-04-17): always do fill if value is *defined*!!!
281      if (defined $value) {
282      ref_slot($self, $name, $value, '.');      ref_slot($self, $name, $value, '.');
283    }    }
284        
# Line 320  sub run_executable { Line 368  sub run_executable {
368    
369    delete $opts->{caption};    delete $opts->{caption};
370    delete $opts->{async};    delete $opts->{async};
371      delete $opts->{detach};
372    
373    #print Dumper($meta);    #print Dumper($meta);
374    
# Line 380  sub run_executable { Line 429  sub run_executable {
429        # V1.b - enhanced: variable local method        # V1.b - enhanced: variable local method
430        $meta->{caption} ||= '';        $meta->{caption} ||= '';
431        $meta->{async} ||= 0;        $meta->{async} ||= 0;
432        my $evalstr = "run_cmd('$cmd', '$meta->{caption}', { async => $meta->{async} });";        $meta->{detach} ||= 0;
433          # new of 2003-05-08: USE_PATH!
434          $meta->{USE_PATH} ||= 0;
435          my $evalstr = "run_cmd('$cmd', '$meta->{caption}', { async => $meta->{async}, detach => $meta->{detach}, USE_PATH => $meta->{USE_PATH} });";
436        eval($evalstr);        eval($evalstr);
437        #my $res = do "$cmd";        #my $res = do "$cmd";
438        #print $res, "\n" if $res;        #print $res, "\n" if $res;
# Line 435  sub run_script { Line 487  sub run_script {
487            
488    } elsif ($args->{language} eq 'bash') {    } elsif ($args->{language} eq 'bash') {
489      $self->log("FIXME: - - - - - -- - - --  BASH -  - -    -  - -   -    --   - ", 'error');      $self->log("FIXME: - - - - - -- - - --  BASH -  - -    -  - -   -    --   - ", 'error');
490    
491      } elsif ($args->{language} eq 'perl') {
492        
493        # reporting
494        #$self->log("Executing some arbitrary unsigned code (probably unsafe). [language=$args->{language}]", 'info');
495        #$self->log("\n<code>\n$code\n</code>", 'info');
496        
497        # do it
498        #eval($code);
499        #$self->log("\n<code>\n$code\n</code>", 'error') if $@;
500            
501    } else {    } else {
502      $self->log("FIXME: Script language '$args->{language}' not implemented.", 'error');      $self->log("FIXME: Script language '$args->{language}' not implemented.", 'error');

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.12

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