Exports

Static members

.createContext([opts])

returns a reporting context for the supplied options

createContext([opts])

returns a reporting context for the supplied options

Parameters

  • [Object] opts (default null) :

    opts

Returns

Context
.createReportSource(a, coverageMap, [opts])

returns a report source for the supplied coverage map and options

createReportSource(a, coverageMap, [opts])

returns a report source for the supplied coverage map and options

Parameters

  • CoverageMap a :

    coverage map

  • coverageMap :
  • [Object] opts (default null) :

    report source options

Returns

ReportSource
.summarizers

standard summary functions

summarizers

standard summary functions

Static members

.flat

a summarizer that creates a flat tree with one root node and bunch of files directly under it

flat

a summarizer that creates a flat tree with one root node and bunch of files directly under it

.nested

a summarizer that creates a hierarchical tree where the coverage summaries of each directly reflect the summaries of all subdirectories and files in it

nested

a summarizer that creates a hierarchical tree where the coverage summaries of each directly reflect the summaries of all subdirectories and files in it

.pkg

a summarizer that creates a tree in which directories are not nested. Every subdirectory is a child of the root node and only reflects the coverage numbers for the files in it (i.e. excludes subdirectories). This is the default summarizer used by the report source.

pkg

a summarizer that creates a tree in which directories are not nested. Every subdirectory is a child of the root node and only reflects the coverage numbers for the files in it (i.e. excludes subdirectories). This is the default summarizer used by the report source.

.getDefaultWatermarks

returns the default watermarks that would be used when not overridden

getDefaultWatermarks

returns the default watermarks that would be used when not overridden

Returns

Object :

an object with statements, functions, branches, and line keys. Each value is a 2 element array that has the low and high watermark as percentages.

ConsoleWriter

Extends ContentWriter

a content writer that writes to the console

ContentWriter

abstract interface for writing content

Instance members

#close

closes this content writer. Should be called after all writes are complete.

close

closes this content writer. Should be called after all writes are complete.

#colorize(str, clazz)

returns the colorized version of a string. Typically, content writers that write to files will return the same string and ones writing to a tty will wrap it in appropriate escape sequences.

colorize(str, clazz)

returns the colorized version of a string. Typically, content writers that write to files will return the same string and ones writing to a tty will wrap it in appropriate escape sequences.

Parameters

  • String str :

    the string to colorize

  • String clazz :

    one of high, medium or low

Returns

String :

the colorized form of the string

#println(str)

writes a string appended with a newline to the destination

println(str)

writes a string appended with a newline to the destination

Parameters

  • String str :

    the string to write

#write(str)

writes a string as-is to the destination

write(str)

writes a string as-is to the destination

Parameters

  • String str :

    the string to write

Context([opts])

A reporting context that is passed to report implementations

Parameters

  • [Object] opts (default null) :

    opts options

    • [String] opts.dir (default 'coverage')

      opts.dir the reporting directory

    • [Object] opts.watermarks (default null)

      opts.watermarks watermarks for statements, lines, branches and functions

    • [Function] opts.sourceFinder (default fsLookup)

      opts.sourceFinder a function that returns source code given a file path. Defaults to filesystem lookups based on path.

Instance members

#classForPercent(type, value)

returns the coverage class given a coverage types and a percentage value.

classForPercent(type, value)

returns the coverage class given a coverage types and a percentage value.

Parameters

  • String type :

    the coverage type, one of statements, functions, branches, or lines

  • Number value :

    the percentage value

Returns

String :

one of high, medium or low

#getSource(filePath)

returns the source code for the specified file path or throws if the source could not be found.

getSource(filePath)

returns the source code for the specified file path or throws if the source could not be found.

Parameters

  • String filePath :

    the file path as found in a file coverage object

Returns

String :

the source code

#getVisitor(partialVisitor)

returns a full visitor given a partial one.

getVisitor(partialVisitor)

returns a full visitor given a partial one.

Parameters

  • Object partialVisitor :

    a partial visitor only having the functions of interest to the caller. These functions are called with a scope that is the supplied object.

Returns

Visitor
#getWriter

returns a FileWriter implementation for reporting use. Also available as the writer property on the context.

getWriter

returns a FileWriter implementation for reporting use. Also available as the writer property on the context.

Returns

Writer
#getXMLWriter(contentWriter)

returns an XML writer for the supplied content writer

getXMLWriter(contentWriter)

returns an XML writer for the supplied content writer

Parameters

  • ContentWriter contentWriter :

    the content writer to which the returned XML writer writes data

Returns

XMLWriter

FileContentWriter(fd)

Extends ContentWriter

a content writer that writes to a file

Parameters

  • Number fd :

    the file descriptor

FileWriter(baseDir)

utility for writing files under a specific directory

Parameters

  • String baseDir :

    the base directory under which files should be written

Instance members

#copyFile(source, dest)

copies a file from a source directory to a destination name

copyFile(source, dest)

copies a file from a source directory to a destination name

Parameters

  • String source :

    path to source file

  • String dest :

    relative path to destination file

#writeFile(file)

returns a content writer for writing content to the supplied file.

writeFile(file)

returns a content writer for writing content to the supplied file.

Parameters

  • String or file :

    the relative path to the file or the special values "-" or null for writing to the console

Returns

ContentWriter
#writerForDir(subdir)

returns a FileWriter that is rooted at the supplied subdirectory

writerForDir(subdir)

returns a FileWriter that is rooted at the supplied subdirectory

Parameters

  • String subdir :

    the subdirectory under which to root the returned FileWriter

Returns

FileWriter

ReportSource(coverageMap, opts)

WIP

Parameters

  • coverageMap :
  • opts :

Tree

abstract base class for a coverage tree.

Instance members

#getRoot

returns the root node of the tree

getRoot

returns the root node of the tree

#visit(visitor, state)

visits the tree depth-first with the supplied partial visitor

visit(visitor, state)

visits the tree depth-first with the supplied partial visitor

Parameters

  • visitor :

    a potentially partial visitor

  • state :

    the state to be passed around during tree traversal

Visitor(delegate)

An object with methods that are called during the traversal of the coverage tree. A visitor has the following methods that are called during tree traversal.

  • onStart(root, state) - called before traversal begins
  • onSummary(node, state) - called for every summary node
  • onDetail(node, state) - called for every detail node
  • onSummaryEnd(node, state) - called after all children have been visited for a summary node.
  • onEnd(root, state) - called after traversal ends

Parameters

  • delegate :

    a partial visitor that only implements the methods of interest The visitor object supplies the missing methods as noops. For example, reports that only need the final coverage summary need implement onStart and nothing else. Reports that use only detailed coverage information need implement onDetail and nothing else.

XMLWriter(contentWriter)

a utility class to produce well-formed, indented XML

Parameters

  • ContentWriter contentWriter :

    the content writer that this utility wraps

Instance members

#closeAll

closes all open tags and ends the document

closeAll

closes all open tags and ends the document

#closeTag(name)

closes an open XML tag.

closeTag(name)

closes an open XML tag.

Parameters

  • String name :

    tag name to close. This must match the writer's notion of the tag that is currently open.

#inlineTag(name, [attrs], [content])

writes a tag and its value opening and closing it at the same time

inlineTag(name, [attrs], [content])

writes a tag and its value opening and closing it at the same time

Parameters

  • String name :

    tag name

  • [Object] attrs (default null) :

    attrs tag attributes

  • [String] content (default null) :

    content optional tag content

#openTag(name, [attrs])

writes the opening XML tag with the supplied attributes

openTag(name, [attrs])

writes the opening XML tag with the supplied attributes

Parameters

  • String name :

    tag name

  • [Object] attrs (default null) :

    attrs attributes for the tag

visit(visitor, state)

visit all nodes depth-first from this node down. Note that onStart and onEnd are never called on the visitor even if the current node is the root of the tree.

Parameters

  • visitor :

    a full visitor that is called during tree traversal

  • state :

    optional state that is passed around