-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathreporter.js
51 lines (40 loc) · 997 Bytes
/
reporter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
* An instance of Report is used to report results of the verification back to the main lib.
*/
(function() {
'use strict';
function Reporter() {
this.messages = [];
}
Reporter.prototype.initialize = function() {
this.messages = [];
};
Reporter.prototype.error = function(element, rule) {
this.messages.push({
type: 'error',
element: element,
rule: rule
});
};
Reporter.prototype.info = function(element, rule) {
this.messages.push({
type: 'info',
element: element,
rule: rule
});
};
Reporter.prototype.getMessages = function() {
return this.messages;
};
Reporter.prototype.hasMessages = function() {
return (this.messages.length !== 0);
};
Reporter.prototype.print = function() {
var len = this.messages.length;
for (var i = 0; i < len; i++) {
console.log(this.element);
console.log(this.messages[i].message);
}
};
module.exports = new Reporter();
}());