From dd44cf45a171b0c295d0dd0fb5ab327c8bfd88e0 Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Fri, 4 Oct 2002 15:07:15 +0000 Subject: [PATCH] added ability to handle module names with spaces git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1064 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd-web/src/pmd.rb | 15 ++++++++++----- pmd-web/src/webpmd.pl | 25 ++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/pmd-web/src/pmd.rb b/pmd-web/src/pmd.rb index e2f09275d1..9e1c3b4abe 100644 --- a/pmd-web/src/pmd.rb +++ b/pmd-web/src/pmd.rb @@ -54,14 +54,15 @@ class Job end def checkout_code - `cvs -Q -d#{@cvsroot} co #{@moduleDirectory}` + `cvs -Q -d#{@cvsroot} co "#{@moduleDirectory}"` end def run_pmd - cmd="java -jar pmd-1.0rc2.jar #{@sourceDirectory} html rulesets/unusedcode.xml > ../htdocs/reports/#{@unixName}_#{@moduleDirectory}.html" + cmd="java -jar pmd-1.0rc2.jar \"#{@sourceDirectory}\" html rulesets/unusedcode.xml > \"#{reportFile()}\"" + puts "running #{cmd}" `#{cmd}` - arr = IO.readlines("../htdocs/reports/#{@unixName}_#{@moduleDirectory}.html") - newFile=File.open("../htdocs/reports/#{@unixName}_#{@moduleDirectory}.html", "w") + arr = IO.readlines(reportFile()) + newFile=File.open(reportFile(), "w") arr.each do | line | if (line["Error while parsing"] == nil) newFile << line @@ -69,9 +70,13 @@ class Job end newFile.close end + + def reportFile + return "../htdocs/reports/#{@unixName}_#{@moduleDirectory.sub(" ", "")}.html" + end def clear - `rm -rf #{@moduleDirectory}` + `rm -rf "#{@moduleDirectory}"` end def to_s diff --git a/pmd-web/src/webpmd.pl b/pmd-web/src/webpmd.pl index 16fcdfaf26..8bfff89f58 100644 --- a/pmd-web/src/webpmd.pl +++ b/pmd-web/src/webpmd.pl @@ -72,12 +72,13 @@ sub loadProjectList() { my $jobdata=; my ($title,$unixname, $mod, $src) = split(":", $jobdata); my $jobtext=""; - if (-e "../htdocs/reports/${unixname}_${mod}.html") { - $jobtext="${title}"; + if (-e getReportFile($unixname, $mod)) { + my $reportURL=getReportURL(${unixname}, ${mod}); + $jobtext="${title}"; } else { $jobtext=$title; } - my $lines = getLines("../htdocs/reports/${unixname}_${mod}.html"); + my $lines = getLines(getReportFile($unixname, $mod)); $result="${result}${jobtext}http://${unixname}.sf.net/${lines}"; } } @@ -85,6 +86,24 @@ 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);