All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scoverage.reporter.CoberturaXmlWriter.scala Maven / Gradle / Ivy

package scoverage.reporter

import java.io.File

import scala.xml.Node
import scala.xml.PrettyPrinter

import scoverage.domain.Coverage
import scoverage.domain.DoubleFormat
import scoverage.domain.MeasuredClass
import scoverage.domain.MeasuredMethod
import scoverage.domain.MeasuredPackage

/** @author Stephen Samuel */
class CoberturaXmlWriter(
    sourceDirectories: Seq[File],
    outputDir: File,
    sourceEncoding: Option[String]
) extends BaseReportWriter(sourceDirectories, outputDir, sourceEncoding) {

  def this(baseDir: File, outputDir: File, sourceEncoding: Option[String]) = {
    this(Seq(baseDir), outputDir, sourceEncoding)
  }

  def write(coverage: Coverage): Unit = {
    val file = new File(outputDir, "cobertura.xml")
    IOUtils.writeToFile(
      file,
      "\n\n" +
        new PrettyPrinter(120, 4).format(xml(coverage)),
      sourceEncoding
    )
  }

  def method(method: MeasuredMethod): Node = {
    
      
        {
          method.statements.map(stmt => )
        }
      
    
  }

  def klass(klass: MeasuredClass): Node = {
    
      
        {klass.methods.map(method)}
      
      
        {
          klass.statements.map(stmt => )
        }
      
    
  }

  def pack(pack: MeasuredPackage): Node = {
    
      
        {pack.classes.map(klass)}
      
    
  }

  def source(src: File): Node = {
    {src.getCanonicalPath.replace(File.separator, "/")}
  }

  def xml(coverage: Coverage): Node = {
    
      
        --source
        {sourceDirectories.filter(_.isDirectory).map(source)}
      
      
        {coverage.packages.map(pack)}
      
    
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy