Просмотр исходного кода

Moving modules, Logfile pm goes into Pisg/Parser/ and the format dependent
code in Pisg/Parser/Format.

Also updated the Makefile so it can distribute our new modules

Morten Brix Pedersen 25 лет назад
Родитель
Сommit
f9aa32ef9f

+ 29 - 0
Makefile

@@ -17,6 +17,7 @@ FILES = pisg.pl \
 	 pisg.cfg \
 	 lang.txt
 
+MODULES = 
 
 GFX = gfx/green-h.png \
 	 gfx/green-v.png \
@@ -35,16 +36,44 @@ ADDALIAS = scripts/addalias/addalias.htm \
 	    scripts/addalias/addalias.pl \
 	    scripts/addalias/README
 
+MODULESDIR = modules
+
+PISG_MODULES = $(MODULESDIR)/Pisg/Common.pm
+
+PARSER_MODULES = $(MODULESDIR)/Pisg/Parser/Logfile.pm
+
+FORMAT_MODULES = $(MODULESDIR)/Pisg/Parser/Format/bxlog.pm \
+		 $(MODULESDIR)/Pisg/Parser/Format/eggdrop.pm \
+		 $(MODULESDIR)/Pisg/Parser/Format/grufti.pm \
+		 $(MODULESDIR)/Pisg/Parser/Format/mbot.pm \
+		 $(MODULESDIR)/Pisg/Parser/Format/mIRC.pm \
+		 $(MODULESDIR)/Pisg/Parser/Format/Template.pm \
+		 $(MODULESDIR)/Pisg/Parser/Format/xchat.pm \
+
 pisg:
 	mkdir -p newrelease
+
 	mkdir $(DIRNAME)
 	cp $(FILES) $(DIRNAME)
+
 	mkdir $(DIRNAME)/scripts
 	cp $(SCRIPTS) $(DIRNAME)/scripts
+
 	mkdir $(DIRNAME)/gfx
 	cp $(GFX) $(DIRNAME)/gfx
+
 	mkdir $(DIRNAME)/scripts/addalias
 	cp $(ADDALIAS) $(DIRNAME)/scripts/addalias
+
+	mkdir $(DIRNAME)/$(MODULESDIR)
+
+	mkdir $(DIRNAME)/$(MODULESDIR)/Pisg
+	mkdir $(DIRNAME)/$(MODULESDIR)/Pisg/Parser
+	mkdir $(DIRNAME)/$(MODULESDIR)/Pisg/Parser/Format
+	cp $(PISG_MODULES) $(DIRNAME)/$(MODULESDIR)/Pisg/
+	cp $(PARSER_MODULES) $(DIRNAME)/$(MODULESDIR)/Pisg/Parser
+	cp $(FORMAT_MODULES) $(DIRNAME)/$(MODULESDIR)/Pisg/Parser/Format
+
 	tar zcfv newrelease/pisg-$(VERSION).tar.gz $(DIRNAME)
 	zip -r pisg $(DIRNAME)
 	mv pisg.zip newrelease/$(ZIPFILE)

+ 1 - 1
modules/Pisg/Parser/Template.pm → modules/Pisg/Parser/Format/Template.pm

@@ -2,7 +2,7 @@
 # necessary changes to the template, you will need to add the new module to
 # pisg.pl and add an entry for it in the choose_log_format subroutine.
 
-package Pisg::Parser::Template;
+package Pisg::Parser::Format::Template;
 
 use strict;
 $^W = 1;

+ 1 - 1
modules/Pisg/Parser/bxlog.pm → modules/Pisg/Parser/Format/bxlog.pm

@@ -1,4 +1,4 @@
-package Pisg::Parser::bxlog;
+package Pisg::Parser::Format::bxlog;
 
 use strict;
 $^W = 1;

+ 1 - 1
modules/Pisg/Parser/eggdrop.pm → modules/Pisg/Parser/Format/eggdrop.pm

@@ -1,4 +1,4 @@
-package Pisg::Parser::eggdrop;
+package Pisg::Parser::Format::eggdrop;
 
 use strict;
 $^W = 1;

+ 1 - 1
modules/Pisg/Parser/grufti.pm → modules/Pisg/Parser/Format/grufti.pm

@@ -1,4 +1,4 @@
-package Pisg::Parser::grufti;
+package Pisg::Parser::Format::grufti;
 
 use strict;
 $^W = 1;

+ 1 - 1
modules/Pisg/Parser/mIRC.pm → modules/Pisg/Parser/Format/mIRC.pm

@@ -1,4 +1,4 @@
-package Pisg::Parser::mIRC;
+package Pisg::Parser::Format::mIRC;
 
 use strict;
 $^W = 1;

+ 0 - 0
modules/Pisg/Parser/mbot.pm → modules/Pisg/Parser/Format/mbot.pm


+ 1 - 1
modules/Pisg/Parser/xchat.pm → modules/Pisg/Parser/Format/xchat.pm

@@ -1,4 +1,4 @@
-package Pisg::Parser::xchat;
+package Pisg::Parser::Format::xchat;
 
 use strict;
 $^W = 1;

+ 8 - 6
modules/Pisg/Logfile.pm → modules/Pisg/Parser/Logfile.pm

@@ -1,4 +1,4 @@
-package Pisg::Logfile;
+package Pisg::Parser::Logfile;
 
 use strict;
 $^W = 1;
@@ -29,8 +29,8 @@ sub choose_log_format {
     $debug->("Loading module for log format $format");
     eval <<_END;
 use lib '$conf->{modules_dir}';
-use Pisg::Parser::$format;
-\$parser = new Pisg::Parser::$format(\$debug);
+use Pisg::Parser::Format::$format;
+\$parser = new Pisg::Parser::Format::$format(\$debug);
 _END
     if ($@) {
         print STDERR "Could not load parser for '$format': $@\n";
@@ -94,9 +94,11 @@ sub parse_dir {
     die("No files in \"$conf->{logdir}\" matched prefix \"$conf->{prefix}\"");
     closedir(LOGDIR);
 
-    my %state = (lastnick   => "",
-    monocount  => 0,
-    oldtime    => 24);
+    my %state = (
+        lastnick   => "",
+        monocount  => 0,
+        oldtime    => 24
+    );
     foreach my $file (sort @filesarray) {
         $file = $conf->{logdir} . $file;
         parse_file($stats, $lines, $file, \%state);

+ 2 - 2
pisg.pl

@@ -143,8 +143,8 @@ sub do_channel
     # Pick our stats generator.
     my $analyzer;
     eval <<_END;
-use Pisg::$conf->{logtype};
-\$analyzer = new Pisg::$conf->{logtype}(\$conf, \$debug);
+use Pisg::Parser::$conf->{logtype};
+\$analyzer = new Pisg::Parser::$conf->{logtype}(\$conf, \$debug);
 _END
     if ($@) {
         print STDERR "Could not load stats generator for '$conf->{logtype}': $@\n";