@@ -38,6 +38,11 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
38
38
}
39
39
40
40
def _file (mfile : MeasuredFile ): Node = {
41
+
42
+ val filename = {
43
+ mfile.source.replace(sourceDirectory.getAbsolutePath + " /" , " " ) + " .html"
44
+ }
45
+
41
46
val css =
42
47
" table.codegrid { font-family: monospace; font-size: 12px; width: auto!important; }" +
43
48
" table.statementlist { width: auto!important; font-size: 13px; } " +
@@ -47,7 +52,7 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
47
52
<head >
48
53
<meta http-equiv =" Content-Type" content =" text/html; charset=utf-8" />
49
54
<title id =' title' >
50
- {mfile.source }
55
+ {filename }
51
56
</title >
52
57
<link rel =" stylesheet" href =" http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" />
53
58
<script src =" http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script >
@@ -139,12 +144,12 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
139
144
def packageClasses (pack : MeasuredPackage ): Node = {
140
145
<html >
141
146
{head}<body style =" font-family: monospace;" >
142
- {classes(pack.classes)}
147
+ {classes(pack.classes, false )}
143
148
</body >
144
149
</html >
145
150
}
146
151
147
- def classes (classes : Iterable [MeasuredClass ]): Node = {
152
+ def classes (classes : Iterable [MeasuredClass ], addPath : Boolean ): Node = {
148
153
<table class =" table table-striped" style =" font-size:13px" >
149
154
<thead >
150
155
<tr >
@@ -185,15 +190,26 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
185
190
</tr >
186
191
</thead >
187
192
<tbody >
188
- {classes.toSeq.sortBy(_.simpleName) map _class}
193
+ {classes.toSeq.sortBy(_.simpleName) map ( _class(_, addPath)) }
189
194
</tbody >
190
195
</table >
191
196
}
192
197
193
- def _class (klass : MeasuredClass ): Node = {
198
+ def _class (klass : MeasuredClass , addPath : Boolean ): Node = {
194
199
195
200
val filename = {
196
- outputDir + klass.source.replace(sourceDirectory.getAbsolutePath, " " ) + " .html"
201
+ val Match = " (.*/)?([^/]+.scala.html)$" .r
202
+ klass.source.replace(sourceDirectory.getAbsolutePath + " /" , " " ) + " .html" match {
203
+ case Match (path, value) => {
204
+ if (addPath && path.eq(null )) {
205
+ " <empty>/" + value
206
+ } else if (addPath && path.ne(" " )) {
207
+ path + value
208
+ } else {
209
+ value
210
+ }
211
+ }
212
+ }
197
213
}
198
214
199
215
val statement0f = Math .round(klass.statementCoveragePercent).toInt.toString
@@ -387,7 +403,7 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
387
403
{stats(coverage)}
388
404
</div >
389
405
<div >
390
- {classes(coverage.classes)}
406
+ {classes(coverage.classes, true )}
391
407
</div >
392
408
</div >
393
409
</body >
0 commit comments