@@ -17,8 +17,8 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
1717
1818 val index = IOUtils .readStreamAsString(getClass.getResourceAsStream(" /scoverage/index.html" ))
1919 IOUtils .writeToFile(indexFile, index)
20- IOUtils .writeToFile(packageFile, packageList(coverage).toString)
21- IOUtils .writeToFile(overviewFile, overview(coverage).toString)
20+ IOUtils .writeToFile(packageFile, packageList(coverage).toString() )
21+ IOUtils .writeToFile(overviewFile, overview(coverage).toString() )
2222
2323 coverage.packages.foreach(writePackage)
2424 }
@@ -31,15 +31,15 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
3131 // to com.example.html
3232 val file = new File (outputDir, packageOverviewRelativePath(pkg))
3333 file.getParentFile.mkdirs()
34- IOUtils .writeToFile(file, packageOverview(pkg).toString)
34+ IOUtils .writeToFile(file, packageOverview(pkg).toString() )
3535 pkg.files.foreach(writeFile)
3636 }
3737
3838 private def writeFile (mfile : MeasuredFile ): Unit = {
3939 // each highlighted file is written out using the same structure as the original file.
4040 val file = new File (outputDir, relativeSource(mfile.source) + " .html" )
4141 file.getParentFile.mkdirs()
42- IOUtils .writeToFile(file, filePage(mfile).toString)
42+ IOUtils .writeToFile(file, filePage(mfile).toString() )
4343 }
4444
4545 private def packageOverviewRelativePath (pkg : MeasuredPackage ) = pkg.name.replace(" <empty>" , " (empty)" ) + " .html"
@@ -57,10 +57,7 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
5757 <title id =' title' >
5858 {filename}
5959 </title >
60- <link rel =" stylesheet" href =" http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" />
61- <script src =" http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script >
62- <script src =" http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js" ></script >
63- <script src =" http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.18.3/addons/pager/jquery.tablesorter.pager.min.js" ></script >
60+ {plugins}
6461 <style >
6562 {css}
6663 </style >
@@ -135,21 +132,13 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
135132 | overflow: hidden;
136133 |}""" .stripMargin
137134
138- val tableScript = """ $(document).ready(function() {$("#packages").tablesorter();});"""
139-
140135 <head >
141136 <meta http-equiv =" Content-Type" content =" text/html; charset=utf-8" />
142137 <title id =' title' >Scoverage Code Coverage </title >
143- <link rel =" stylesheet" href =" http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" />
144- <script src =" http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script >
145- <script src =" http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js" ></script >
146- <script src =" http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.18.3/addons/pager/jquery.tablesorter.pager.min.js" ></script >
138+ {plugins}
147139 <style >
148140 {css}
149141 </style >
150- <script >
151- {tableScript}
152- </script >
153142 </head >
154143 }
155144
@@ -282,29 +271,25 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
282271 <title id =' title' >
283272 Scoverage Code Coverage
284273 </title >
285- <link rel =" stylesheet" href =" http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" />
286- <script src =" http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script >
287- <script src =" http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js" ></script >
288- <script src =" http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.18.3/addons/pager/jquery.tablesorter.pager.min.js" ></script >
274+ {plugins}
289275 </head >
290276 <body style =" font-family: monospace;" >
291- <table class =" table table-striped" style =" font-size: 13px" >
292- <tbody >
277+ <table class =" tablesorter table table-striped" style =" font-size: 13px" >
278+ <thead >
293279 <tr >
294280 <td >
295- <a href =" overview.html" target =" mainFrame" >
296- All packages
297- </a >{coverage.statementCoverageFormatted}
298- %
281+ <a href =" overview.html" target =" mainFrame" >All packages</a >
299282 </td >
300- </tr >{coverage.packages.map(arg =>
283+ <td >{coverage.statementCoverageFormatted}%</ td>
284+ </tr >
285+ </thead >
286+ <tbody >
287+ {coverage.packages.map(arg =>
301288 <tr >
302289 <td >
303- <a href ={packageOverviewRelativePath(arg)} target =" mainFrame" >
304- {arg.name}
305- </a >{arg.statementCoverageFormatted}
306- %
290+ <a href ={packageOverviewRelativePath(arg)} target =" mainFrame" >{arg.name}</a >
307291 </td >
292+ <td >{arg.statementCoverageFormatted}%</ td>
308293 </tr >
309294 )}
310295 </tbody >
@@ -314,7 +299,7 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
314299 }
315300
316301 def risks (coverage : Coverage , limit : Int ) = {
317- <table id = " packages " class =" table table-striped" style =" font-size: 12px" >
302+ <table class =" tablesorter table table-striped" style =" font-size: 12px" >
318303 <thead >
319304 <tr >
320305 <th >
@@ -535,5 +520,16 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
535520 </tr >
536521 </table >
537522 }
523+
524+ def plugins = {
525+ <script src =" http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script >
526+ <link rel =" stylesheet" href =" https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.20.1/css/theme.default.min.css" type =" text/css" />
527+ <script src =" http://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.20.1/js/jquery.tablesorter.min.js" ></script >
528+ <link rel =" stylesheet" href =" http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" type =" text/css" />
529+ <script src =" http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js" ></script >
530+ <script type =" text/javascript" >
531+ {xml.Unparsed (""" $(document).ready(function() {$(".tablesorter").tablesorter();});""" )}
532+ </script >
533+ }
538534}
539535
0 commit comments