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

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

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

revision 1.5 by jonen, Fri Mar 28 16:52:41 2003 UTC revision 1.8 by joko, Fri Dec 5 04:59:33 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## -------------------------------------------------------------------------  ## -------------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.8  2003/12/05 04:59:33  joko
6    ##  + minor update: disabled some unnecessary loggers
7    ##
8    ##  Revision 1.7  2003/05/13 05:52:58  joko
9    ##  minor update: modified description printing logic
10    ##
11    ##  Revision 1.6  2003/03/29 07:08:56  joko
12    ##  rap goes global:
13    ##    + distinguish between running in global- or project-mode
14    ##    + some comments in pod
15    ##
16  ##  Revision 1.5  2003/03/28 16:52:41  jonen  ##  Revision 1.5  2003/03/28 16:52:41  jonen
17  ##  now using env-var 'RAPBIN'  ##  now using env-var 'RAPBIN'
18  ##  ##
# Line 34  Line 45 
45    A Process is a Task.    A Process is a Task.
46    There are just details.    There are just details.
47    
48    
49  =head2 ahh...  =head2 ahh...
50    
51    CPAN already *has got* all the tools starting an attempt to do this.    rap means 'Request And Process'.
52      rap is contained in 'wrapped'.
53      dot is the 'Database Of Targets', by default '/etc/rap.xml'. (rename to 'dot.xml'?)
54    
55    
56      CPAN already *has got* all required tools starting an attempt to do this.
57        
58    Having enough experience with Perl now, this attempt should work out well.....    Will this work out?
59    But still, Hmmm......    But still, Hmmm......
60    And: lots of work, i believe....    And: lots of work, i believe....
61      Let's start...
62        
63    Okay:    Okay:
64    Look at DesignPattern:: and Data::Mungle::Transform::Deep & Co. (lowlevel stuff)    Look at DesignPattern:: and Data::Mungle::Transform::Deep & Co. (lowlevel stuff)
# Line 70  Line 88 
88    
89  =head2 Rap - Request And Process  =head2 Rap - Request And Process
90    
91    =head3 Rap's Features
92      - have targets (like make) declared in xml (like ant)
93      - run these targets...
94        - ... from a multitude of possible human interaction devices (HIDs), e.g.
95          - cli (console mode)
96          - gui
97          - web
98          - speech
99          - scribe
100        - ... from a different location (non-local - for remote administration purposes)
101          - the remote wrapper is 'rapd' - the rap-daemon....
102          - rapd can run in command-mode (like apache, sendmail and related)
103            and/or web-service mode (commands are wrapped into request-/response-
104            xml-payload-communication)
105      - rap is self contained on various levels
106        - runtime-layer
107          - pass arguments between targets
108          - core targets are declared in xml (rap-lingo) as well
109            these exist by now: (look at Data/Rap/targets/default.xml)
110            - core.os.win32
111            - core.os.linux
112            - core.rap.mode
113            - core.rap.daemon
114        - declaration-layer
115          - the xml-file in rap-lingo can contain descriptions associated with each target
116          - rap can make report on its guis about these
117          - rap can use this declaration as an api for the rap-daemon 'rapd'
118        - rap itself can run in "global"- or "project"-mode
119          - FIXME: write something about this (by now: read the source, luke.....)
120          
121    
122    =head3 Rap's Future
123      - rapd
124        - rapd can also run in apache mode for non-root purposes
125        - many rapd's can talk to each other - first example application would be:
126          - one rapd is running as apache-mod-perl-handler (non-root)
127          - one rapd is running locally as root
128          - remark: the way to go (by now) is via org.netfrag.glib's DataSource-libraries,
129            which wrap the innards of rpc-communication via xml (XMLRPC) (lingo: php)
130            an example application is caesar.rapweb and (maybe) caesar.ums
131    
132  =head3 Rap's aims are directed to get some of this together  =head3 Rap's aims are directed to get some of this together
133    
# Line 166  use Cwd; Line 224  use Cwd;
224  use File::Spec::Functions qw( splitpath splitdir catpath catdir );  use File::Spec::Functions qw( splitpath splitdir catpath catdir );
225    
226    
227    # a package global topic registry
228    our $registry;
229    
230    
231  sub constructor {  sub constructor {
232    my $self = shift;    my $self = shift;
233        
# Line 183  sub constructor { Line 245  sub constructor {
245    #$self->load("Metadata");    #$self->load("Metadata");
246    #$self->load("Engine");    #$self->load("Engine");
247    
   # check for another environment-variable: 'RAPBIN'  
   chdir $ENV{RAPBIN} if $ENV{RAPBIN};  
     
248  }  }
249    
250  sub start {  sub start {
251    my $self = shift;    my $self = shift;
252    $self->log("starting", 'info');    #$self->log("starting", 'info');
253        
254    $self->loadGlobalProperties();    $self->loadGlobalProperties();
255        
256    #print Dumper($self);    #print Dumper($self);
257    if (my $target = $self->{target}) {    if (my $target = $self->{target}) {
258      #$self->{targets}->{$target} = Data::Rap::Target->new( name => $target );      #$self->{targets}->{$target} = Data::Rap::Target->new( name => $target );
259      $self->log("target: $target", 'info');      #$self->log("target: $target", 'info');
260      $self->performTarget($target);      $self->performTarget($target);
261    } else {    } else {
262      my $meta_raw = $self->getTargetList();      my $meta_raw = $self->getTargetList();
263    
264        my $maxlength = 0;
265        map {
266          my $len = length($_->{name});
267          $maxlength = $len if $len > $maxlength;
268        } @$meta_raw;
269    
270        my $program = splitpath($0);
271      foreach my $entry (@$meta_raw) {      foreach my $entry (@$meta_raw) {
272        print "  - rap.pl $entry->{name}", "\n";        my $len = length($entry->{name});
273        print $entry->{description}, "\n" if $entry->{description};        #$len = ((1 / ($len / 8)) * 1.9);
274          #$len = ((1 / ($maxlength - $len / 8)) * 1.9);
275          $len = $maxlength - $len + 5;
276          #print "len: $len", "\n";
277          # one line per target
278          print "$program $entry->{name}", " " x $len;
279          print $entry->{description} if $entry->{description};
280          print "\n";
281          # more lines per target
282          #print "$program $entry->{name}", "\n";
283          #print "   ", $entry->{description}, "\n" if $entry->{description};
284      }      }
285    
286      return;      return;
# Line 232  sub start { Line 308  sub start {
308  sub find_rules {  sub find_rules {
309    my $self = shift;    my $self = shift;
310    
311    my $basedir;    my $rapfile = 'etc/rap.xml';
312      my $rapfile_found = '';
313      
314      my $basedir = '';
315      
316      # directly from env-var?
317    if (my $rapdir = $ENV{RAPDIR}) {    if (my $rapdir = $ENV{RAPDIR}) {
318      $basedir = $rapdir;      $basedir = $rapdir;
319    } else {      
320      # relative?
321      } else {
322      my $cwd = cwd();      my $cwd = cwd();
323    
324      (my $volume, my $directory, my $file) = splitpath( $cwd );      (my $volume, my $directory, my $file) = splitpath( $cwd );
325    
326      my @dir = splitdir($directory);      my @dir = splitdir($directory);
327      pop @dir;      pop @dir;
328      #pop @dir;      #pop @dir;
329      $basedir = catpath($volume, catdir(@dir));      $basedir = catpath($volume, catdir(@dir));
330        
331      }
332    
333      #print "basedir: '$basedir'", "\n";
334    
335      # check for $basedir/PROJECT
336      if (! -d "$basedir/PROJECT") {
337        $basedir = '';
338    }    }
339    
340    my $rap_xml = "$basedir/etc/rap.xml";    if ($basedir) {
341    return $rap_xml;      # TODO: review this! handle relative ./etc/rap.xml here!!!
342        $rapfile_found = "$basedir/$rapfile";
343      
344      } else {
345        #if (! -e $rapfile_found) { $rapfile_found = "/$rapfile"; }
346        $rapfile_found = "/$rapfile";
347      }
348        
349      #print "rapfile_found: $rapfile_found", "\n";
350    
351    
352      # if rapfile doesn't exists, try to fall back to absolute (global) mode (/etc/rap.xml)
353      #if (! -e $rapfile_found) { $rapfile_found = catpath($volume, "/", $rapfile); }
354      #if (! -e $rapfile_found) { $rapfile_found = "/$rapfile"; }
355    
356      $self->log( "Using rapfile $rapfile_found.", 'info' );
357    
358      return $rapfile_found;
359  }  }
360    
361    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.8

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