--- nfo/perl/libs/Data/Rap.pm 2003/03/27 15:31:01 1.4 +++ nfo/perl/libs/Data/Rap.pm 2003/12/05 04:59:33 1.8 @@ -1,7 +1,21 @@ ## ------------------------------------------------------------------------- -## $Id: Rap.pm,v 1.4 2003/03/27 15:31:01 joko Exp $ +## $Id: Rap.pm,v 1.8 2003/12/05 04:59:33 joko Exp $ ## ------------------------------------------------------------------------- ## $Log: Rap.pm,v $ +## Revision 1.8 2003/12/05 04:59:33 joko +## + minor update: disabled some unnecessary loggers +## +## Revision 1.7 2003/05/13 05:52:58 joko +## minor update: modified description printing logic +## +## Revision 1.6 2003/03/29 07:08:56 joko +## rap goes global: +## + distinguish between running in global- or project-mode +## + some comments in pod +## +## Revision 1.5 2003/03/28 16:52:41 jonen +## now using env-var 'RAPBIN' +## ## Revision 1.4 2003/03/27 15:31:01 joko ## fixes to modules regarding new namespace(s) below Data::Mungle::* ## @@ -31,13 +45,20 @@ A Process is a Task. There are just details. + =head2 ahh... - CPAN already *has got* all the tools starting an attempt to do this. + rap means 'Request And Process'. + rap is contained in 'wrapped'. + dot is the 'Database Of Targets', by default '/etc/rap.xml'. (rename to 'dot.xml'?) + + + CPAN already *has got* all required tools starting an attempt to do this. - Having enough experience with Perl now, this attempt should work out well..... + Will this work out? But still, Hmmm...... And: lots of work, i believe.... + Let's start... Okay: Look at DesignPattern:: and Data::Mungle::Transform::Deep & Co. (lowlevel stuff) @@ -67,6 +88,46 @@ =head2 Rap - Request And Process +=head3 Rap's Features + - have targets (like make) declared in xml (like ant) + - run these targets... + - ... from a multitude of possible human interaction devices (HIDs), e.g. + - cli (console mode) + - gui + - web + - speech + - scribe + - ... from a different location (non-local - for remote administration purposes) + - the remote wrapper is 'rapd' - the rap-daemon.... + - rapd can run in command-mode (like apache, sendmail and related) + and/or web-service mode (commands are wrapped into request-/response- + xml-payload-communication) + - rap is self contained on various levels + - runtime-layer + - pass arguments between targets + - core targets are declared in xml (rap-lingo) as well + these exist by now: (look at Data/Rap/targets/default.xml) + - core.os.win32 + - core.os.linux + - core.rap.mode + - core.rap.daemon + - declaration-layer + - the xml-file in rap-lingo can contain descriptions associated with each target + - rap can make report on its guis about these + - rap can use this declaration as an api for the rap-daemon 'rapd' + - rap itself can run in "global"- or "project"-mode + - FIXME: write something about this (by now: read the source, luke.....) + + +=head3 Rap's Future + - rapd + - rapd can also run in apache mode for non-root purposes + - many rapd's can talk to each other - first example application would be: + - one rapd is running as apache-mod-perl-handler (non-root) + - one rapd is running locally as root + - remark: the way to go (by now) is via org.netfrag.glib's DataSource-libraries, + which wrap the innards of rpc-communication via xml (XMLRPC) (lingo: php) + an example application is caesar.rapweb and (maybe) caesar.ums =head3 Rap's aims are directed to get some of this together @@ -163,6 +224,10 @@ use File::Spec::Functions qw( splitpath splitdir catpath catdir ); +# a package global topic registry +our $registry; + + sub constructor { my $self = shift; @@ -179,26 +244,43 @@ #$self->load("Command"); #$self->load("Metadata"); #$self->load("Engine"); - + } sub start { my $self = shift; - $self->log("starting", 'info'); + #$self->log("starting", 'info'); $self->loadGlobalProperties(); #print Dumper($self); if (my $target = $self->{target}) { #$self->{targets}->{$target} = Data::Rap::Target->new( name => $target ); - $self->log("target: $target", 'info'); + #$self->log("target: $target", 'info'); $self->performTarget($target); } else { my $meta_raw = $self->getTargetList(); + my $maxlength = 0; + map { + my $len = length($_->{name}); + $maxlength = $len if $len > $maxlength; + } @$meta_raw; + + my $program = splitpath($0); foreach my $entry (@$meta_raw) { - print " - rap.pl $entry->{name}", "\n"; - print $entry->{description}, "\n" if $entry->{description}; + my $len = length($entry->{name}); + #$len = ((1 / ($len / 8)) * 1.9); + #$len = ((1 / ($maxlength - $len / 8)) * 1.9); + $len = $maxlength - $len + 5; + #print "len: $len", "\n"; + # one line per target + print "$program $entry->{name}", " " x $len; + print $entry->{description} if $entry->{description}; + print "\n"; + # more lines per target + #print "$program $entry->{name}", "\n"; + #print " ", $entry->{description}, "\n" if $entry->{description}; } return; @@ -225,16 +307,55 @@ sub find_rules { my $self = shift; - my $cwd = cwd(); - (my $volume, my $directory, my $file) = splitpath( $cwd ); - my @dir = splitdir($directory); - pop @dir; - #pop @dir; - my $base = catpath($volume, catdir(@dir)); + my $rapfile = 'etc/rap.xml'; + my $rapfile_found = ''; + + my $basedir = ''; + + # directly from env-var? + if (my $rapdir = $ENV{RAPDIR}) { + $basedir = $rapdir; + + # relative? + } else { + my $cwd = cwd(); + + (my $volume, my $directory, my $file) = splitpath( $cwd ); + + my @dir = splitdir($directory); + pop @dir; + #pop @dir; + $basedir = catpath($volume, catdir(@dir)); + + } + + #print "basedir: '$basedir'", "\n"; + + # check for $basedir/PROJECT + if (! -d "$basedir/PROJECT") { + $basedir = ''; + } + + if ($basedir) { + # TODO: review this! handle relative ./etc/rap.xml here!!! + $rapfile_found = "$basedir/$rapfile"; + + } else { + #if (! -e $rapfile_found) { $rapfile_found = "/$rapfile"; } + $rapfile_found = "/$rapfile"; + } + + #print "rapfile_found: $rapfile_found", "\n"; + + + # if rapfile doesn't exists, try to fall back to absolute (global) mode (/etc/rap.xml) + #if (! -e $rapfile_found) { $rapfile_found = catpath($volume, "/", $rapfile); } + #if (! -e $rapfile_found) { $rapfile_found = "/$rapfile"; } + + $self->log( "Using rapfile $rapfile_found.", 'info' ); - my $rap_xml = "$base/etc/rap.xml"; - return $rap_xml; + return $rapfile_found; }