cssified reports, made everything look prettyish
This commit is contained in:
parent
dafa6ebffa
commit
627c95ed81
17
build.xml
17
build.xml
@ -39,13 +39,20 @@
|
||||
<target name="product" depends="init, set-revision-number" description="Generates Product.php (product meta information)">
|
||||
<exec executable="php">
|
||||
<arg line="${dir.tools}/productize.php"/>
|
||||
<arg line="-n ${product.name}"/>
|
||||
<arg line="-v ${product.version}.${product.revision}"/>
|
||||
<arg line="-n"/>
|
||||
<arg line="${product.name}"/>
|
||||
<arg line="-v"/>
|
||||
<arg line="${product.version}.${product.revision}"/>
|
||||
<arg line="-a"/>
|
||||
<arg line="${product.author}"/>
|
||||
<arg line="-w ${product.website}"/>
|
||||
<arg line="-p ${ant.project.name}"/>
|
||||
<arg line="-o ${dir.src}/${ant.project.name}/util/Product.php"/>
|
||||
<arg line="-e"/>
|
||||
<arg line="${product.ezc}"/>
|
||||
<arg line="-w"/>
|
||||
<arg line="${product.website}"/>
|
||||
<arg line="-p"/>
|
||||
<arg line="${ant.project.name}"/>
|
||||
<arg line="-o"/>
|
||||
<arg line="${dir.src}/${ant.project.name}/util/Product.php"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
|
@ -2,3 +2,4 @@ name=TUnit
|
||||
version=0.5.0
|
||||
author="Tommy Montgomery"
|
||||
website=http://tommymontgomery.com/
|
||||
ezc=1.0
|
@ -13,7 +13,6 @@
|
||||
$newData = array();
|
||||
foreach ($coverageData as $file => $data) {
|
||||
$classes = Util::getClassNamesFromFile($file);
|
||||
//print_r($classes);
|
||||
$refClasses = array();
|
||||
|
||||
foreach ($classes as $class) {
|
||||
@ -167,9 +166,17 @@
|
||||
$tcloc += $methodData['cloc'];
|
||||
|
||||
$methodStartLine = $refClass->getMethod($method)->getStartLine();
|
||||
$methodCoverage .= "<tr class=\"method-coverage\"><th> <a href=\"#line-$methodStartLine\">$method</a></th>";
|
||||
$methodCoverage .= "<td>$methodData[cloc] / " . ($methodData['loc'] - $methodData['dloc']) . "</td>";
|
||||
$methodCoverage .= "<td>" . round($methodData['cloc'] / ($methodData['loc'] - $methodData['dloc']) * 100, 2) . "%</td></tr>\n";
|
||||
$methodDeclaration = $method . '(';
|
||||
|
||||
$refMethod = $refClass->getMethod($method);
|
||||
$methodDeclaration .= Util::buildParameterDefinition($refMethod) . ')';
|
||||
unset($refMethod);
|
||||
|
||||
$percentageData = self::getPercentage($methodData['cloc'], $methodData['loc'] - $methodData['dloc']);
|
||||
|
||||
$methodCoverage .= "<tr class=\"method-coverage\"><th> <a href=\"#line-$methodStartLine\">$methodDeclaration</a></th>";
|
||||
$methodCoverage .= "<td class=\"coverage-ratio\" style=\"background-color: $percentageData[1]\">$methodData[cloc] / " . ($methodData['loc'] - $methodData['dloc']) . "</td>";
|
||||
$methodCoverage .= "<td class=\"coverage-percentage\" style=\"background-color: $percentageData[1]\">$percentageData[0]%</td></tr>\n";
|
||||
|
||||
$classLoc += $methodData['loc'];
|
||||
$classDloc += $methodData['dloc'];
|
||||
@ -177,8 +184,10 @@
|
||||
}
|
||||
|
||||
$classStartLine = $refClass->getStartLine();
|
||||
$classCoverage .= "<tr class=\"class-coverage\"><th> <a href=\"#line-$classStartLine\">$class</a></th><td>$classCloc / " . ($classLoc - $classDloc) . "</td>";
|
||||
$classCoverage .= "<td>" . round($classCloc / ($classLoc - $classDloc) * 100, 2) . "%</td></tr>\n";
|
||||
$percentageData = self::getPercentage($classCloc, $classLoc - $classDloc);
|
||||
$classCoverage .= "<tr class=\"class-coverage\"><th> <a href=\"#line-$classStartLine\">$class</a></th>";
|
||||
$classCoverage .= "<td class=\"coverage-ratio\" style=\"background-color: $percentageData[1]\">$classCloc / " . ($classLoc - $classDloc) . "</td>";
|
||||
$classCoverage .= "<td class=\"coverage-percentage\" style=\"background-color: $percentageData[1]\">$percentageData[0]%</td></tr>\n";
|
||||
$classCoverage .= $methodCoverage;
|
||||
}
|
||||
|
||||
@ -186,8 +195,10 @@
|
||||
$tdloc += $classData['procedural']['dloc'];
|
||||
$tcloc += $classData['procedural']['cloc'];
|
||||
|
||||
$fileCoveragePercent = round($tcloc / max($tloc - $tdloc, 1) * 100, 2);
|
||||
$fileCoverage = "<tr class=\"file-coverage\"><th>$sourceFile</th><td>$tcloc / " . ($tloc - $tdloc) . "</td><td>$fileCoveragePercent%</td></tr>\n";
|
||||
$percentageData = self::getPercentage($tcloc, $tloc - $tdloc);
|
||||
$fileCoverage = "<tr class=\"file-coverage\"><th>$sourceFile</th>";
|
||||
$fileCoverage .= "<td class=\"coverage-percentage\" style=\"background-color: $percentageData[1]\">$tcloc / " . ($tloc - $tdloc) . "</td>";
|
||||
$fileCoverage .= "<td class=\"coverage-ratio\" style=\"background-color: $percentageData[1]\">$percentageData[0]%</td></tr>\n";
|
||||
$fileCoverage .= $classCoverage;
|
||||
unset($classCoverage, $methodCoverage, $classData, $refClass);
|
||||
|
||||
@ -197,7 +208,7 @@
|
||||
$lineNumbers = '';
|
||||
|
||||
for ($i = 1, $len = count($lines); $i <= $len; $i++) {
|
||||
$lineNumbers .= '<div><a name="#line-' . $i . '" href="#line-' . $i . '">' . $i . '</a></div>';
|
||||
$lineNumbers .= '<div><a name="line-' . $i . '" href="#line-' . $i . '">' . $i . '</a></div>';
|
||||
$code .= '<div';
|
||||
if (isset($coverageData[$i])) {
|
||||
$code .= ' class="';
|
||||
@ -239,7 +250,10 @@
|
||||
'${product.name}',
|
||||
'${product.version}',
|
||||
'${product.website}',
|
||||
'${product.author}'
|
||||
'${product.author}',
|
||||
'${php.version}',
|
||||
'${xdebug.version}',
|
||||
'${ezc.version}'
|
||||
),
|
||||
array(
|
||||
Product::NAME . ' - Coverage Report',
|
||||
@ -251,7 +265,10 @@
|
||||
Product::NAME,
|
||||
Product::VERSION,
|
||||
Product::WEBSITE,
|
||||
Product::AUTHOR
|
||||
Product::AUTHOR,
|
||||
phpversion(),
|
||||
phpversion('xdebug'),
|
||||
Product::EZC_VERSION
|
||||
),
|
||||
$template
|
||||
);
|
||||
@ -319,17 +336,19 @@
|
||||
}
|
||||
$subdata = $dirData[$subdir];
|
||||
|
||||
$percentageData = self::getPercentage($subdata['cloc'], $subdata['loc'] - $subdata['dloc']);
|
||||
$info .= '<tr><th><a href="' . self::buildLink($baseDir, $subdir . DIRECTORY_SEPARATOR . 'foo', true) . '.html">' . basename($subdir) . '</a></th>';
|
||||
$info .= '<td>' . $subdata['cloc'] . ' / ' . ($subdata['loc'] - $subdata['dloc']) . '</td>';
|
||||
$info .= '<td>' . round($subdata['cloc'] / ($subdata['loc'] - $subdata['dloc']) * 100, 2) . '%</td>';
|
||||
$info .= '<td class="coverage-ratio" style="background-color: ' . $percentageData[1] . '">' . $subdata['cloc'] . ' / ' . ($subdata['loc'] - $subdata['dloc']) . '</td>';
|
||||
$info .= "<td class=\"coverage-percentage\" style=\"background-color: $percentageData[1]\">$percentageData[0]%</td>";
|
||||
$info .= "</tr>\n";
|
||||
}
|
||||
|
||||
//regular files in current directory
|
||||
foreach ($data['files'] as $file => $fileData) {
|
||||
$percentageData = self::getPercentage($fileData['cloc'], $fileData['loc'] - $fileData['dloc']);
|
||||
$info .= '<tr><th><a href="' . self::buildLink($baseDir, $file, true) . '-' . basename($file) . '.html">' . basename($file) . '</a></th>';
|
||||
$info .= '<td>' . $fileData['cloc'] . ' / ' . ($fileData['loc'] - $fileData['dloc']) . '</td>';
|
||||
$info .= '<td>' . round($fileData['cloc'] / ($fileData['loc'] - $fileData['dloc']) * 100, 2) . '%</td>';
|
||||
$info .= '<td class="coverage-ratio" style="background-color: ' . $percentageData[1] . '">' . $fileData['cloc'] . ' / ' . ($fileData['loc'] - $fileData['dloc']) . '</td>';
|
||||
$info .= "<td class=\"coverage-percentage\" style=\"background-color: $percentageData[1]\">$percentageData[0]%</td>";
|
||||
$info .= "</tr>\n";
|
||||
}
|
||||
|
||||
@ -342,7 +361,10 @@
|
||||
'${product.name}',
|
||||
'${product.version}',
|
||||
'${product.website}',
|
||||
'${product.author}'
|
||||
'${product.author}',
|
||||
'${php.version}',
|
||||
'${xdebug.version}',
|
||||
'${ezc.version}'
|
||||
),
|
||||
array(
|
||||
Product::NAME . ' - Coverage Report',
|
||||
@ -352,7 +374,10 @@
|
||||
Product::NAME,
|
||||
Product::VERSION,
|
||||
Product::WEBSITE,
|
||||
Product::AUTHOR
|
||||
Product::AUTHOR,
|
||||
phpversion(),
|
||||
phpversion('xdebug'),
|
||||
Product::EZC_VERSION
|
||||
),
|
||||
$template
|
||||
);
|
||||
@ -368,6 +393,7 @@
|
||||
} else {
|
||||
$link = '<a href="./index.html">' . $baseDir . '</a>';
|
||||
}
|
||||
|
||||
$dirs = preg_split('@\\' . DIRECTORY_SEPARATOR . '@', str_replace($baseDir, '', dirname($path) . DIRECTORY_SEPARATOR), -1, PREG_SPLIT_NO_EMPTY);
|
||||
$path = '';
|
||||
foreach ($dirs as $dir) {
|
||||
@ -376,6 +402,7 @@
|
||||
} else {
|
||||
$path = $path . '-' . $dir;
|
||||
}
|
||||
|
||||
if ($oneLink) {
|
||||
$link = $path;
|
||||
} else {
|
||||
@ -394,6 +421,25 @@
|
||||
return $old + (($new > 0) ? 1 : 0);
|
||||
}
|
||||
|
||||
private static function getPercentage($numerator, $denominator) {
|
||||
$percentage = ($denominator != 0) ? round($numerator / $denominator * 100, 2) : 0;
|
||||
$percentage = number_format($percentage, 2);
|
||||
return array(
|
||||
str_repeat(' ', 6 - strlen($percentage)) . $percentage,
|
||||
self::getCoverageColor($percentage)
|
||||
);
|
||||
}
|
||||
|
||||
private static function getCoverageColor($percentage) {
|
||||
$color = '#';
|
||||
|
||||
$color .= str_pad(dechex(255 - round($percentage * 2.55)), 2, '0', STR_PAD_LEFT);
|
||||
$color .= str_pad(dechex(round($percentage * 2.55)), 2, '0', STR_PAD_LEFT);
|
||||
$color .= '33';
|
||||
|
||||
return $color;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -13,18 +13,32 @@
|
||||
<div id="wrapper">
|
||||
|
||||
<div id="header">
|
||||
<h1>${file.link}</h1>
|
||||
<h1>${product.name} Code Coverage Report</h1>
|
||||
</div>
|
||||
|
||||
<div id="file-link">
|
||||
<p>${file.link}</p>
|
||||
</div>
|
||||
|
||||
<div id="directory-coverage">
|
||||
<table>
|
||||
<colgroup>
|
||||
<col style="width:50%"/>
|
||||
<col style="width:25%"/>
|
||||
<col style="width:25%"/>
|
||||
</colgroup>
|
||||
|
||||
${directory.coverage}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Generated on ${timestamp} by <a href="${product.website}">${product.name} ${product.version}</a>
|
||||
Generated on ${timestamp} by <a href="${product.website}" title="${product.name}">${product.name} ${product.version}</a>
|
||||
<br />
|
||||
<a href="http://php.net/" title="PHP">PHP ${php.version}</a> |
|
||||
<a href="http://xdebug.org/" title="Xdebug">Xdebug ${xdebug.version}</a> |
|
||||
<a href="http://ezcomponents.org/" title="ezComponents">ezComponents ${ezc.version}</a>
|
||||
<br />
|
||||
© 2009 ${product.author}
|
||||
</p>
|
||||
|
@ -13,14 +13,25 @@
|
||||
<div id="wrapper">
|
||||
|
||||
<div id="header">
|
||||
<h1>${file.link}</h1>
|
||||
<h1>${product.name} Code Coverage Report</h1>
|
||||
</div>
|
||||
|
||||
<div id="file-link">
|
||||
<p>${file.link}</p>
|
||||
</div>
|
||||
|
||||
<div id="summary">
|
||||
<table>
|
||||
<colgroup>
|
||||
<col width="50%"/>
|
||||
<col width="25%"/>
|
||||
<col width="25%"/>
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<td></td><th colspan="3">Coverage</th>
|
||||
<td></td><th colspan="2">Coverage</th>
|
||||
</tr>
|
||||
</thead>
|
||||
${file.coverage}
|
||||
</table>
|
||||
</div>
|
||||
@ -36,7 +47,11 @@ ${code}
|
||||
|
||||
<div id="footer">
|
||||
<p>
|
||||
Generated on ${timestamp} by <a href="${product.website}">${product.name} ${product.version}</a>
|
||||
Generated on ${timestamp} by <a href="${product.website}" title="${product.name}">${product.name} ${product.version}</a>
|
||||
<br />
|
||||
<a href="http://php.net/" title="PHP">PHP ${php.version}</a> |
|
||||
<a href="http://xdebug.org/" title="Xdebug">Xdebug ${xdebug.version}</a> |
|
||||
<a href="http://ezcomponents.org/" title="ezComponents">ezComponents ${ezc.version}</a>
|
||||
<br />
|
||||
© 2009 ${product.author}
|
||||
</p>
|
||||
|
@ -2,11 +2,48 @@ html {
|
||||
overflow: auto;
|
||||
}
|
||||
body {
|
||||
background-color: #FFFFCC;
|
||||
background-color: #CCFFCC;
|
||||
color: #000000;
|
||||
font-family: Consolas, "Courier New", monospace;
|
||||
font-size: 16px;
|
||||
}
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #990099;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
table {
|
||||
background-color: #FFFFFF;
|
||||
border-collapse: collapse;
|
||||
border: 2px solid #000000;
|
||||
width: 100%;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid #000000;
|
||||
padding: .3em;
|
||||
}
|
||||
th {
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
}
|
||||
thead th {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#file-link {
|
||||
text-align: center;
|
||||
}
|
||||
#file-link a {
|
||||
color: #990000;
|
||||
display: inline-block;
|
||||
margin-right: 5px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#code-wrapper {
|
||||
background-color: #FFFFFF;
|
||||
@ -42,16 +79,21 @@ body {
|
||||
background-color: #FFFFFF;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
#summary th {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#footer {
|
||||
text-align: center;
|
||||
font-family: Verdana, sans-serif;
|
||||
font-size: 8pt;
|
||||
font-size: 12px;
|
||||
}
|
||||
#footer a {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.coverage-percentage {
|
||||
text-align: center;
|
||||
}
|
||||
.coverage-ratio {
|
||||
text-align: center;
|
||||
}
|
||||
.covered {
|
||||
background-color: #66FF66;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@
|
||||
$paramList = '';
|
||||
foreach ($method->getParameters() as $i => $param) {
|
||||
if ($param->getClass()) {
|
||||
$paramList .= $param->getClass() . ' ';
|
||||
$paramList .= $param->getClass()->getName() . ' ';
|
||||
} else if ($param->isArray()) {
|
||||
$paramList .= 'array ';
|
||||
}
|
||||
@ -89,13 +89,18 @@
|
||||
if ($param->isOptional()) {
|
||||
$paramList .= ' = ';
|
||||
if ($param->isDefaultValueAvailable()) {
|
||||
if (is_array($param->getDefaultValue())) {
|
||||
//removes annoying spaces in parens
|
||||
$paramList .= 'array()';
|
||||
} else {
|
||||
$paramList .= var_export($param->getDefaultValue(), true);
|
||||
}
|
||||
} else {
|
||||
$paramList .= 'null';
|
||||
}
|
||||
}
|
||||
|
||||
$paramList .= ',';
|
||||
$paramList .= ', ';
|
||||
}
|
||||
|
||||
return rtrim($paramList, ', ');
|
||||
|
@ -26,6 +26,7 @@
|
||||
->addSwitch(new CliSwitch('version', 'v', true, 'version_number', 'Product version'))
|
||||
->addSwitch(new CliSwitch('author', 'a', true, 'author_name', 'Product author'))
|
||||
->addSwitch(new CliSwitch('website', 'w', true, 'url', 'Product website'))
|
||||
->addSwitch(new CliSwitch('ezc', 'e', true, 'version', 'ezComponents version number'))
|
||||
->addSwitch(new CliSwitch('package', 'p', true, 'package_name ', 'Name of the package for use in @package tag'))
|
||||
->addSwitch(new CliSwitch('doc-version', 'd', false, 'version_number', 'Version number for use in @version tag'))
|
||||
->addSwitch(new CliSwitch('output', 'o', false, 'file|dir', 'The file/directory to write the generated class to; default is stdout'));
|
||||
@ -97,6 +98,11 @@
|
||||
* Product build date
|
||||
*/
|
||||
const DATE = '$datetime';
|
||||
|
||||
/**
|
||||
* ezComponents version
|
||||
*/
|
||||
const EZC_VERSION = '$args[ezc]';
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user