Skip to content

Enable sorting in HTML report #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 3, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {

val index = IOUtils.readStreamAsString(getClass.getResourceAsStream("/scoverage/index.html"))
IOUtils.writeToFile(indexFile, index)
IOUtils.writeToFile(packageFile, packageList(coverage).toString)
IOUtils.writeToFile(overviewFile, overview(coverage).toString)
IOUtils.writeToFile(packageFile, packageList(coverage).toString())
IOUtils.writeToFile(overviewFile, overview(coverage).toString())

coverage.packages.foreach(writePackage)
}
Expand All @@ -31,15 +31,15 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
// to com.example.html
val file = new File(outputDir, packageOverviewRelativePath(pkg))
file.getParentFile.mkdirs()
IOUtils.writeToFile(file, packageOverview(pkg).toString)
IOUtils.writeToFile(file, packageOverview(pkg).toString())
pkg.files.foreach(writeFile)
}

private def writeFile(mfile: MeasuredFile): Unit = {
// each highlighted file is written out using the same structure as the original file.
val file = new File(outputDir, relativeSource(mfile.source) + ".html")
file.getParentFile.mkdirs()
IOUtils.writeToFile(file, filePage(mfile).toString)
IOUtils.writeToFile(file, filePage(mfile).toString())
}

private def packageOverviewRelativePath(pkg: MeasuredPackage) = pkg.name.replace("<empty>", "(empty)") + ".html"
Expand All @@ -57,10 +57,7 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
<title id='title'>
{filename}
</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.18.3/addons/pager/jquery.tablesorter.pager.min.js"></script>
{plugins}
<style>
{css}
</style>
Expand Down Expand Up @@ -135,21 +132,13 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
| overflow: hidden;
|}""".stripMargin

val tableScript = """$(document).ready(function() {$("#packages").tablesorter();});"""

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title id='title'>Scoverage Code Coverage</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.18.3/addons/pager/jquery.tablesorter.pager.min.js"></script>
{plugins}
<style>
{css}
</style>
<script>
{tableScript}
</script>
</head>
}

Expand Down Expand Up @@ -282,29 +271,25 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
<title id='title'>
Scoverage Code Coverage
</title>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.18.3/addons/pager/jquery.tablesorter.pager.min.js"></script>
{plugins}
</head>
<body style="font-family: monospace;">
<table class="table table-striped" style="font-size: 13px">
<tbody>
<table class="tablesorter table table-striped" style="font-size: 13px">
<thead>
<tr>
<td>
<a href="overview.html" target="mainFrame">
All packages
</a>{coverage.statementCoverageFormatted}
%
<a href="overview.html" target="mainFrame">All packages</a>
</td>
</tr>{coverage.packages.map(arg =>
<td>{coverage.statementCoverageFormatted}%</td>
</tr>
</thead>
<tbody>
{coverage.packages.map(arg =>
<tr>
<td>
<a href={packageOverviewRelativePath(arg)} target="mainFrame">
{arg.name}
</a>{arg.statementCoverageFormatted}
%
<a href={packageOverviewRelativePath(arg)} target="mainFrame">{arg.name}</a>
</td>
<td>{arg.statementCoverageFormatted}%</td>
</tr>
)}
</tbody>
Expand All @@ -314,7 +299,7 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
}

def risks(coverage: Coverage, limit: Int) = {
<table id="packages" class="table table-striped" style="font-size: 12px">
<table class="tablesorter table table-striped" style="font-size: 12px">
<thead>
<tr>
<th>
Expand Down Expand Up @@ -535,5 +520,16 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
</tr>
</table>
}

def plugins = {
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.20.1/css/theme.default.min.css" type="text/css"/>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.20.1/js/jquery.tablesorter.min.js"></script>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" type="text/css"/>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script type="text/javascript">
{xml.Unparsed("""$(document).ready(function() {$(".tablesorter").tablesorter();});""")}
</script>
}
}