- From: Olivier Thereaux <ot@dev.w3.org>
- Date: Mon, 16 Aug 2004 02:42:20 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/perl/modules/W3C/LogValidator/samples
In directory hutz:/tmp/cvs-serv3356
Modified Files:
NewModule.pm
Log Message:
updating template + API doc
Index: NewModule.pm
===================================================================
RCS file: /sources/public/perl/modules/W3C/LogValidator/samples/NewModule.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- NewModule.pm 28 Mar 2004 19:31:42 -0000 1.7
+++ NewModule.pm 16 Aug 2004 02:42:18 -0000 1.8
@@ -31,7 +31,7 @@
my $proto = shift;
my $class = ref($proto) || $proto;
# mandatory vars for the API
- $self->{URIS} = undef;
+ @{$self->{URIs}} = undef;
# internal stuff here
# $self->{FOO} = undef;
@@ -43,6 +43,14 @@
}
+sub uris
+{
+ my $self = shift;
+ if (@_) { @{$self->{URIs}} = @_ }
+ return @{$self->{URIs}};
+}
+
+
# internal routines
#sub foobar
#{
@@ -62,21 +70,33 @@
my $max_invalid = undef;
if (exists $config{MaxInvalid}) {$max_invalid = $config{MaxInvalid}
print "Now Using the CHANGEME module :\n" if $verbose;
- use DB_File;
- my $tmp_file = $config{tmpfile};
- my %hits;
- tie (%hits, 'DB_File', "$tmp_file", O_RDONLY) ||
- die ("Cannot create or open $tmp_file");
- my @uris = sort { $hits{$b} <=> $hits{$a} } keys %hits;
+
+ my @uris = undef;
+ my %hits;
+ # Opening the file with the hits and URIs data
+ if (defined ($config{tmpfile}))
+ {
+ use DB_File;
+ my $tmp_file = $config{tmpfile};
+ tie (%hits, 'DB_File', "$tmp_file", O_RDONLY) ||
+ die ("Cannot create or open $tmp_file");
+ @uris = sort { $hits{$b} <=> $hits{$a} } keys %hits;
+ }
+ elsif ($self->uris())
+ {
+ @uris = $self->uris();
+ foreach my $uri (@uris) { $hits{$uri} = 0 }
+ }
# do what pleases you!
print "Done!\n" if $verbose;
-
- untie %hits;
-
+ if (defined ($config{tmpfile}))
+ {
+ untie %hits;
+ }
# Here is what the module will return. The hash will be sent to
# the output module
@@ -108,7 +128,7 @@
=head1 NAME
-W3C::LogValidator::NewModule - Sample New processing module for the Log Validator
+W3C::LogValidator::NewModule - New processing module Template for the Log Validator
=head1 SYNOPSIS
@@ -116,15 +136,74 @@
=head1 DESCRIPTION
-This module is part of the W3C::LogValidator suite, and ....
+Note: please change this description when using this module code and documentation as a template.
+
+This module is a template for the creation of a new processing module for the W3C Log Validator
+
+
+-head1 API
+
+=head2 Constructor
+
+=over 2
+
+=item $proc = W3C::LogValidator::NewModule->new
+
+Constructs a new C<W3C::LogValidator:NewModule> processor.
+
+You might pass it a configuration hash reference (see L<W3C::LogValidator/config_module> and L<W3C::LogValidator::Config>)
+
+ $proc = W3C::LogValidator::NewModule->new(\%config);
+
+=back
+
+=head2 Main processing method
+
+=over 4
+
+=item $proc->process_list
+
+Processes a list of sorted URIs (through whatever you want your module to be useful for)
+
+The list can be set C<uris>. If the $val was given a config has when constructed, and if the has has a "tmpfile" key,
+C<process_list> will try to read this file as a hash of URIs and "hits" (popularity) with L<DB_File>.
+
+Returns a result hash. Keys for this hash are:
+
+ name (string): the name of the module
+ intro (string): introduction to the processing results
+ thead (array): headers of the results table
+ trows (array of arrays): rows of the results table
+ outro (string): conclusion of the processing results
+
+=back
+
+=head2 General methods
+
+=over 4
+
+=item $proc->uris
+
+Returns a list of URIs to be processed (unless the configuration gives the location for the hash of URI/hits berkeley file, see C<process_list>
+If an array is given as a parameter, also sets the list of URIs and returns it.
+
+
+=back
+
+Note: please document other methods here.
+
+See also L<W3c::LogValidator::HTMLValidator> for a few other interesting methods you could copy.
+
=head1 AUTHOR
-you <your@address>
+Template created by olivier Thereaux <ot@w3.org> for W3C
+
+Module created by You <your@address>
=head1 SEE ALSO
W3C::LogValidator::LogProcessor, perl(1).
-Up-to-date complete info at http://www.w3.org/QA/Tools/LogValidator/
+Up-to-date complete info at L<http://www.w3.org/QA/Tools/LogValidator/>
=cut
Received on Monday, 16 August 2004 02:42:20 UTC