API Docs for: 0.9.3
Show:

File: lib/coverage.js

  1. // Copyright 2014, Yahoo! Inc.
  2. // Copyrights licensed under the Mit License. See the accompanying LICENSE file for terms.
  3.  
  4. var Base = require('preceptor-core').Base;
  5. var utils = require('preceptor-core').utils;
  6. var _ = require('underscore');
  7.  
  8. var defaultOptions = require('./defaults/defaultCoverage');
  9.  
  10. /**
  11. * @class Coverage
  12. * @extends Base
  13. *
  14. * @property {object} _options
  15. */
  16. var Coverage = Base.extend(
  17.  
  18. /**
  19. * Coverage constructor
  20. *
  21. * @param {object} options
  22. * @constructor
  23. */
  24. function (options) {
  25. this.__super();
  26.  
  27. this._options = utils.deepExtend({}, [ defaultOptions, options || {} ]);
  28.  
  29. this.initialize();
  30. },
  31.  
  32. {
  33. /**
  34. * Initializes the instance
  35. *
  36. * @method initialize
  37. */
  38. initialize: function () {
  39. // Nothing yet
  40. },
  41.  
  42.  
  43. /**
  44. * Gets the client-driver instance
  45. *
  46. * @method getInstance
  47. * @return {*}
  48. */
  49. getInstance: function () {
  50. return this._instance;
  51. },
  52.  
  53. /**
  54. * Gets the options
  55. *
  56. * @method getOptions
  57. * @return {object}
  58. */
  59. getOptions: function () {
  60. return this._options;
  61. },
  62.  
  63.  
  64. /**
  65. * Is coverage active?
  66. *
  67. * @method isActive
  68. * @return {string}
  69. */
  70. isActive: function () {
  71. return !!this.getOptions().active;
  72. },
  73.  
  74. /**
  75. * Get path to where the coverage data should be written to
  76. *
  77. * @method getPath
  78. * @return {string}
  79. */
  80. getPath: function () {
  81. return this.getOptions().path;
  82. },
  83.  
  84. /**
  85. * Gets the root-directory
  86. *
  87. * @method getRoot
  88. * @return {string}
  89. */
  90. getRoot: function () {
  91. return this.getOptions().root;
  92. },
  93.  
  94. /**
  95. * Gets the type of reports to create
  96. *
  97. * @method getReports
  98. * @return {string}
  99. */
  100. getReports: function () {
  101. return this.getOptions().reports;
  102. },
  103.  
  104. /**
  105. * Get includes for coverage
  106. *
  107. * @method getIncludes
  108. * @return {string[]}
  109. */
  110. getIncludes: function () {
  111. return this.getOptions().includes;
  112. },
  113.  
  114. /**
  115. * Get excludes for coverage
  116. *
  117. * @method getExcludes
  118. * @return {string[]}
  119. */
  120. getExcludes: function () {
  121. return this.getOptions().excludes;
  122. },
  123.  
  124.  
  125. /**
  126. * Exports data to an object
  127. *
  128. * @method toObject
  129. * @return {object}
  130. */
  131. toObject: function () {
  132. return utils.deepExtend({}, [this.getOptions()]);
  133. }
  134. },
  135.  
  136. {
  137. /**
  138. * @property TYPE
  139. * @type {string}
  140. * @static
  141. */
  142. TYPE: 'Coverage'
  143. });
  144.  
  145. module.exports = Coverage;
  146.