/[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.2 by joko, Tue Feb 18 16:02:04 2003 UTC revision 1.7 by joko, Tue May 13 05:52:58 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## -------------------------------------------------------------------------  ## -------------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.7  2003/05/13 05:52:58  joko
6    ##  minor update: modified description printing logic
7    ##
8    ##  Revision 1.6  2003/03/29 07:08:56  joko
9    ##  rap goes global:
10    ##    + distinguish between running in global- or project-mode
11    ##    + some comments in pod
12    ##
13    ##  Revision 1.5  2003/03/28 16:52:41  jonen
14    ##  now using env-var 'RAPBIN'
15    ##
16    ##  Revision 1.4  2003/03/27 15:31:01  joko
17    ##  fixes to modules regarding new namespace(s) below Data::Mungle::*
18    ##
19    ##  Revision 1.3  2003/02/20 18:44:26  joko
20    ##  renamed modules
21    ##  + sub find_rules: attempts to find 'rap.xml'
22    ##  + updated documentation: added SYNOPSIS
23    ##
24  ##  Revision 1.2  2003/02/18 16:02:04  joko  ##  Revision 1.2  2003/02/18 16:02:04  joko
25  ##  +- renamed module  ##  +- renamed module
26  ##  ##
# Line 23  Line 42 
42    A Process is a Task.    A Process is a Task.
43    There are just details.    There are just details.
44    
45    
46  =head2 ahh...  =head2 ahh...
47    
48    CPAN already *has got* all the tools starting an attempt to do this.    rap means 'Request And Process'.
49      rap is contained in 'wrapped'.
50      dot is the 'Database Of Targets', by default '/etc/rap.xml'. (rename to 'dot.xml'?)
51    
52    
53      CPAN already *has got* all required tools starting an attempt to do this.
54        
55    Having enough experience with Perl now, this attempt should work out well.....    Will this work out?
56    But still, Hmmm......    But still, Hmmm......
57    And: lots of work, i believe....    And: lots of work, i believe....
58      Let's start...
59        
60    Okay:    Okay:
61    Look at DesignPattern:: and Data::Transform::Deep & Co. (lowlevel stuff)    Look at DesignPattern:: and Data::Mungle::Transform::Deep & Co. (lowlevel stuff)
62    or OEF::, Data::Storage and Data::Transfer::Sync (highlevel stuff).    or OEF::, Data::Storage and Data::Transfer::Sync (highlevel stuff).
63    
64    And then:    And then:
65    
66    
67    =head1 SYNOPSIS
68    
69      my $rap = Data::Rap->new( target => 'sync-core' );
70      $rap->start();
71    
72      print Dumper($rap);
73      
74      print Dumper($rap->get_property('/'));
75    
76      print Dumper($rap->get_property('.'));
77      print Dumper($rap->get_property('global'));
78      print Dumper($rap->get_property('app'));
79      print Dumper($rap->get_property('app.config'));
80      print Dumper($rap->get_property('app.config.preboot'));
81      print Dumper($rap->get_property('app.config.databases.oefcore'));
82    
83    
84  =head1 Overview  =head1 Overview
85    
86  =head2 Rap - Request And Process  =head2 Rap - Request And Process
87    
88    =head3 Rap's Features
89      - have targets (like make) declared in xml (like ant)
90      - run these targets...
91        - ... from a multitude of possible human interaction devices (HIDs), e.g.
92          - cli (console mode)
93          - gui
94          - web
95          - speech
96          - scribe
97        - ... from a different location (non-local - for remote administration purposes)
98          - the remote wrapper is 'rapd' - the rap-daemon....
99          - rapd can run in command-mode (like apache, sendmail and related)
100            and/or web-service mode (commands are wrapped into request-/response-
101            xml-payload-communication)
102      - rap is self contained on various levels
103        - runtime-layer
104          - pass arguments between targets
105          - core targets are declared in xml (rap-lingo) as well
106            these exist by now: (look at Data/Rap/targets/default.xml)
107            - core.os.win32
108            - core.os.linux
109            - core.rap.mode
110            - core.rap.daemon
111        - declaration-layer
112          - the xml-file in rap-lingo can contain descriptions associated with each target
113          - rap can make report on its guis about these
114          - rap can use this declaration as an api for the rap-daemon 'rapd'
115        - rap itself can run in "global"- or "project"-mode
116          - FIXME: write something about this (by now: read the source, luke.....)
117          
118    
119    =head3 Rap's Future
120      - rapd
121        - rapd can also run in apache mode for non-root purposes
122        - many rapd's can talk to each other - first example application would be:
123          - one rapd is running as apache-mod-perl-handler (non-root)
124          - one rapd is running locally as root
125          - remark: the way to go (by now) is via org.netfrag.glib's DataSource-libraries,
126            which wrap the innards of rpc-communication via xml (XMLRPC) (lingo: php)
127            an example application is caesar.rapweb and (maybe) caesar.ums
128    
129  =head3 Rap's aims are directed to get some of this together  =head3 Rap's aims are directed to get some of this together
130    
# Line 55  Line 138 
138         - OEF::Component::Task         - OEF::Component::Task
139      - make "old" shortcut programs like "feed.pl", "tell.pl" and such obsolete      - make "old" shortcut programs like "feed.pl", "tell.pl" and such obsolete
140      - add more targets in order to make "setup.pl" & Co. obsolete as well      - add more targets in order to make "setup.pl" & Co. obsolete as well
141      - some new concepts (perly):
142        - namespaces
143        - plugins
144        - contexts
145    
146    
147  =head3 It's using these fine modules from CPAN  =head3 It's using these fine modules from CPAN
# Line 73  Line 160 
160    
161  =head3 Rap does networking  =head3 Rap does networking
162    
163    - It's a client. (cli program, standalone)    x It's a client. (cli program, standalone)
164    - It's a server/daemon as well. (cli interacts with daemon via tcp-socket)        (->Command-Frontends: rap.pl)
165      o It's a server/daemon as well. (cli interacts with daemonized engine via tcp-socket)
166          (->Command-Frontends: rap.pl --remote|--host=<hostname>)
167    
168        
169  =head3 Rap is open for enhancements and/or integration into/with other stuff  =head3 Rap is open for enhancements and/or integration into/with other stuff
170    
171  =head4 Command-Frontends (local and/or remote)  =head4 Command-Frontends (local and/or remote)
172    
173      x rap.pl
174    o Commands can be sent via psh (The Perl Shell) or similar frontends (via rap.pl or Rap.pm)    o Commands can be sent via psh (The Perl Shell) or similar frontends (via rap.pl or Rap.pm)
175    o Commands can be issued from a php-frontend (via RPC using Rap::)    o Commands can be issued from a php-frontend (via RPC using Rap::)
176    
# Line 121  use warnings; Line 211  use warnings;
211  use base qw(  use base qw(
212    DesignPattern::Object    DesignPattern::Object
213    DesignPattern::Bridge    DesignPattern::Bridge
214    Log::Dispatch::Config::Object    DesignPattern::Logger
215      DesignPattern::Exception
216  );  );
217    
218    
219  use Data::Dumper;  use Data::Dumper;
220    use Cwd;
221    use File::Spec::Functions qw( splitpath splitdir catpath catdir );
222    
223    
224    # a package global topic registry
225    our $registry;
226    
227    
228  sub constructor {  sub constructor {
229    my $self = shift;    my $self = shift;
230    $self->load([qw( Metadata Engine Property Command )]);    
231      # patch
232        $self->{__rap}->{filename} = $self->{filename};
233        delete $self->{filename};
234      
235      # check
236        if (!$self->{__rap}->{filename}) {
237          $self->{__rap}->{filename} = $self->find_rules();
238        }
239      
240      $self->load([qw( Metadata Engine Command Context Property )]);
241    #$self->load("Command");    #$self->load("Command");
242    #$self->load("Metadata");    #$self->load("Metadata");
243    #$self->load("Engine");    #$self->load("Engine");
244      
245  }  }
246    
247  sub start {  sub start {
# Line 149  sub start { Line 256  sub start {
256      $self->log("target: $target", 'info');      $self->log("target: $target", 'info');
257      $self->performTarget($target);      $self->performTarget($target);
258    } else {    } else {
259      my $meta_raw = $self->readXmlOverview();      my $meta_raw = $self->getTargetList();
260      #print Dumper($meta_raw);  
261        my $maxlength = 0;
262        map {
263          my $len = length($_->{name});
264          $maxlength = $len if $len > $maxlength;
265        } @$meta_raw;
266    
267        my $program = splitpath($0);
268        foreach my $entry (@$meta_raw) {
269          my $len = length($entry->{name});
270          #$len = ((1 / ($len / 8)) * 1.9);
271          #$len = ((1 / ($maxlength - $len / 8)) * 1.9);
272          $len = $maxlength - $len + 5;
273          #print "len: $len", "\n";
274          # one line per target
275          print "$program $entry->{name}", " " x $len;
276          print $entry->{description} if $entry->{description};
277          print "\n";
278          # more lines per target
279          #print "$program $entry->{name}", "\n";
280          #print "   ", $entry->{description}, "\n" if $entry->{description};
281        }
282    
283        return;
284    
285        print Dumper($meta_raw);
286        exit;
287        
288      foreach my $key (keys %{$meta_raw->{target}}) {      foreach my $key (keys %{$meta_raw->{target}}) {
289        my $target = $meta_raw->{target}->{$key};        my $target = $meta_raw->{target}->{$key};
290        print "  - rap.pl $key", "\n";        print "  - rap.pl $key", "\n";
# Line 168  sub start { Line 302  sub start {
302        
303  }  }
304    
305    sub find_rules {
306      my $self = shift;
307    
308      my $rapfile = 'etc/rap.xml';
309      my $rapfile_found = '';
310      
311      my $basedir = '';
312      
313      # directly from env-var?
314      if (my $rapdir = $ENV{RAPDIR}) {
315        $basedir = $rapdir;
316    
317      # relative?
318      } else {
319        my $cwd = cwd();
320    
321        (my $volume, my $directory, my $file) = splitpath( $cwd );
322    
323        my @dir = splitdir($directory);
324        pop @dir;
325        #pop @dir;
326        $basedir = catpath($volume, catdir(@dir));
327        
328      }
329    
330      #print "basedir: '$basedir'", "\n";
331    
332      # check for $basedir/PROJECT
333      if (! -d "$basedir/PROJECT") {
334        $basedir = '';
335      }
336    
337      if ($basedir) {
338        # TODO: review this! handle relative ./etc/rap.xml here!!!
339        $rapfile_found = "$basedir/$rapfile";
340      
341      } else {
342        #if (! -e $rapfile_found) { $rapfile_found = "/$rapfile"; }
343        $rapfile_found = "/$rapfile";
344      }
345        
346      #print "rapfile_found: $rapfile_found", "\n";
347    
348    
349      # if rapfile doesn't exists, try to fall back to absolute (global) mode (/etc/rap.xml)
350      #if (! -e $rapfile_found) { $rapfile_found = catpath($volume, "/", $rapfile); }
351      #if (! -e $rapfile_found) { $rapfile_found = "/$rapfile"; }
352    
353      $self->log( "Using rapfile $rapfile_found.", 'info' );
354    
355      return $rapfile_found;
356    }
357    
358    
359  1;  1;
360  __END__  __END__

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.7

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