now webpmd.pl uses objects
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1066 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -3,18 +3,44 @@ package PMD::Project;
|
||||
use Exporter;
|
||||
|
||||
@ISA = ('Exporter');
|
||||
@EXPORT = qw(&new &getTitle &getUnixName &getModuleDir &getSrcDir &getString &getJobsFile);
|
||||
push @EXPORT, '&new';
|
||||
push @EXPORT, '&getTitle';
|
||||
push @EXPORT, '&getUnixName';
|
||||
push @EXPORT, '&getModuleDir';
|
||||
push @EXPORT, '&getSrcDir';
|
||||
push @EXPORT, '&getString';
|
||||
push @EXPORT, '&getJobsFile';
|
||||
push @EXPORT, '&getRptFile';
|
||||
push @EXPORT, '&getRptURL';
|
||||
push @EXPORT, '&getLines';
|
||||
|
||||
sub new {
|
||||
my $self = {};
|
||||
bless($self);
|
||||
$self->{TITLE} = @_[1];
|
||||
$self->{UNIXNAME} = @_[2];
|
||||
$self->{MODULEDIR} = @_[3];
|
||||
$self->{SRCDIR} = @_[4];
|
||||
if ((scalar(@_)-1) == 1) {
|
||||
($self->{TITLE},$self->{UNIXNAME}, $self->{MODULEDIR}, $self->{SRCDIR}) = split(":", @_[1]);
|
||||
} else {
|
||||
$self->{TITLE} = @_[1];
|
||||
$self->{UNIXNAME} = @_[2];
|
||||
$self->{MODULEDIR} = @_[3];
|
||||
$self->{SRCDIR} = @_[4];
|
||||
}
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub getLines() {
|
||||
my $self = shift;
|
||||
open(FILE,getRptFile($self));
|
||||
my @x = <FILE>;
|
||||
close(FILE);
|
||||
my $y = @x;
|
||||
my $lines = sprintf("%0.f", ($y-5)/4);
|
||||
if ($lines == "-0" || $lines == "-1") {
|
||||
$lines = "0";
|
||||
}
|
||||
return $lines;
|
||||
}
|
||||
|
||||
sub getTitle() {
|
||||
my $self = shift;
|
||||
return $self->{TITLE}
|
||||
@ -45,5 +71,23 @@ sub getJobsFile() {
|
||||
return "jobs/$self->{UNIXNAME}_$self->{MODULEDIR}.txt";
|
||||
}
|
||||
|
||||
sub getRptURL() {
|
||||
my $self = shift;
|
||||
my $name = $self->getReportName();
|
||||
return "http://pmd.sf.net/reports/${name}";
|
||||
}
|
||||
|
||||
sub getRptFile() {
|
||||
my $self = shift;
|
||||
my $name = $self->getReportName();
|
||||
return "../htdocs/reports/${name}";
|
||||
}
|
||||
|
||||
sub getReportName() {
|
||||
my $self = shift;
|
||||
my $modwithoutspaces = $self->{MODULEDIR};
|
||||
$modwithoutspaces=~s/\s+//g;
|
||||
return "$self->{UNIXNAME}_${modwithoutspaces}.html";
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -1,4 +1,5 @@
|
||||
pscp tomcopeland@pmd.sourceforge.net:/home/groups/p/pm/pmd/cgi-bin/webpmd.pl .
|
||||
pscp tomcopeland@pmd.sourceforge.net:/home/groups/p/pm/pmd/cgi-bin/pmd.rb .
|
||||
pscp tomcopeland@pmd.sourceforge.net:/home/groups/p/pm/pmd/cgi-bin/processor.rb .
|
||||
pscp tomcopeland@pmd.sourceforge.net:/home/groups/p/pm/pmd/cgi-bin/PMD/Project.pm ./PMD/
|
||||
pscp tomcopeland@pmd.sourceforge.net:/home/groups/p/pm/pmd/cgi-bin/PMD/Project.pm ./PMD/
|
||||
|
||||
|
@ -23,9 +23,7 @@ sub default() {
|
||||
if (param("title")) {
|
||||
my $project = PMD::Project->new(param("title"),param("unixname"), param("moduledirectory"), param("srcdir"));
|
||||
addProject($project);
|
||||
print p();
|
||||
my $title = $project->getTitle();
|
||||
print b("Added ${title} to the schedule");
|
||||
print p(), b("Added "), b($project->getTitle()), b(" to the schedule"), p();
|
||||
}
|
||||
|
||||
print "PMD is run hourly (at 10 minutes past the hour) on these projects:";
|
||||
@ -54,6 +52,7 @@ sub printStats() {
|
||||
print b("Stats:"), br(), "There are ", getTimeUntil(), " minutes until the next run";
|
||||
open(FILE,"lastruntime.txt");
|
||||
my $lastruntime=<FILE>;
|
||||
close(FILE);
|
||||
print br();
|
||||
print "The last run took ", sprintf("%.0f", $lastruntime/60), " minutes";
|
||||
print br();
|
||||
@ -72,15 +71,18 @@ sub loadProjectList() {
|
||||
if ($file =~ /txt/) {
|
||||
open(FILE,"jobs/${file}");
|
||||
my $jobdata=<FILE>;
|
||||
my ($title,$unixname, $mod, $src) = split(":", $jobdata);
|
||||
close(FILE);
|
||||
my $p = PMD::Project->new($jobdata);
|
||||
my $jobtext="";
|
||||
if (-e getReportFile($unixname, $mod)) {
|
||||
my $reportURL=getReportURL(${unixname}, ${mod});
|
||||
$jobtext="<a href=\"${reportURL}\")>${title}</a>";
|
||||
if (-e $p->getRptFile()) {
|
||||
my $reportURL=$p->getRptURL();
|
||||
my $title = $p->getTitle();
|
||||
$jobtext="<a href=\"${reportURL}\">$title</a>";
|
||||
} else {
|
||||
$jobtext=$title;
|
||||
$jobtext=$p->getTitle();
|
||||
}
|
||||
my $lines = getLines(getReportFile($unixname, $mod));
|
||||
my $lines = $p->getLines();
|
||||
my $unixname = $p->getUnixName();
|
||||
$result="${result}<tr><td>${jobtext}</td><td></td><td><a href=\"http://${unixname}.sf.net/\">http://${unixname}.sf.net/</a></td><td>${lines}</td>";
|
||||
}
|
||||
}
|
||||
@ -88,38 +90,6 @@ sub loadProjectList() {
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub getReportURL() {
|
||||
my ($unixname, $mod) = @_;
|
||||
my $name = getReportFileName($unixname, $mod);
|
||||
return "http://pmd.sf.net/reports/${name}";
|
||||
}
|
||||
|
||||
sub getReportFile() {
|
||||
my ($unixname, $mod) = @_;
|
||||
my $name = getReportFileName($unixname, $mod);
|
||||
return "../htdocs/reports/${name}";
|
||||
}
|
||||
|
||||
sub getReportFileName() {
|
||||
my ($unixname, $mod) = @_;
|
||||
$mod=~s/\s+//g;
|
||||
return "${unixname}_${mod}.html";
|
||||
}
|
||||
|
||||
sub getLines() {
|
||||
my ($filename) = @_;
|
||||
open(FILE,$filename);
|
||||
my @x = <FILE>;
|
||||
close(FILE);
|
||||
my $y = @x;
|
||||
my $lines = sprintf("%0.f", ($y-5)/4);
|
||||
if ($lines == "-0" || $lines == "-1") {
|
||||
$lines = "0";
|
||||
}
|
||||
return $lines;
|
||||
}
|
||||
|
||||
|
||||
sub addProject() {
|
||||
my ($project) = @_;
|
||||
my $data = $project->getString();
|
||||
|
Reference in New Issue
Block a user