1+ const _ = require('underscore');
2+
3+ const Table = require('markdown-table');
4+ const Base = require('./base');
5+
6+ const format = {
7+ headline: h => `\n### ${h}\n`,
8+ warning: w => `> ${w}`
9+ };
10+
11+ /**
12+ * stdout table output
13+ */
14+ class table extends Base {
15+ constructor(config, report) {
16+ super(config, report);
17+ this.format = format;
18+ }
19+
20+ makeStats() {
21+ this.headline('TIME STATS');
22+
23+ let stats = '';
24+
25+ _.each(this.stats, (time, name) => stats += `\n* **${name}**: ${time}`);
26+ _.each(this.users, (time, name) => stats += `\n* **${name}**: ${time}`);
27+
28+ this.write(stats.substr(1));
29+ }
30+
31+ makeIssues() {
32+ this.headline('ISSUES');
33+
34+ if (this.report.issues.length === 0)
35+ return this.warning('No issues found');
36+
37+ let issues = [this.config.get('issueColumns')];
38+ this.report.issues.forEach(issue => issues.push(this.prepare(issue, this.config.get('issueColumns'))));
39+
40+ this.write(Table(issues));
41+ }
42+
43+ makeMergeRequests() {
44+ this.headline('MERGE REQUESTS');
45+
46+ if (this.report.mergeRequests.length === 0)
47+ return this.warning('No merge requests found');
48+
49+ let mergeRequests = [this.config.get('mergeRequestColumns')];
50+ this.report.mergeRequests.forEach(mergeRequest => mergeRequests.push(this.prepare(mergeRequest, this.config.get('mergeRequestColumns'))));
51+
52+ this.write(Table(mergeRequests));
53+ }
54+
55+ makeRecords() {
56+ this.headline('TIME RECORDS');
57+
58+ let times = [this.config.get('recordColumns')];
59+ this.times.forEach(time => times.push(this.prepare(time, this.config.get('recordColumns'))));
60+
61+ this.write(Table(times));
62+ }
63+ }
64+
65+ module.exports = table;
0 commit comments