-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdaemon.js
37 lines (26 loc) · 1.14 KB
/
daemon.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
/* global require */
'use strict';
require('pointfree-fantasy').expose(global);
const Rx = require('rx');
Rx.Observable.prototype.chain = Rx.Observable.prototype.flatMap;
const config = require('./config.json');
const fetchRepository = require('./lib/travis.js');
const geckoboard = require('./lib/geckoboard.js');
const renderRepositories = require('./lib/repositoriesToHtml.js');
const fetchRepositories = compose(Rx.Observable.zipArray, map(fetchRepository));
const pushToWidget = curry(geckoboard.customText)(config.geckoboard.api_key, config.geckoboard.widget_key);
const htmlsToWidgetItems = function(htmls) {
return [{text: htmls.join('\n'), type: 0}];
};
const pushHtmlsAsWidgetItems = compose(pushToWidget, htmlsToWidgetItems);
const fetchRenderPush = compose(chain(pushHtmlsAsWidgetItems), map(renderRepositories), chain(fetchRepositories));
const repositoriesTrigger = Rx.Observable.interval(config.interval * 1000).map(K(config.repos));
fetchRenderPush(repositoriesTrigger)
.subscribe(
function(response) {
console.log(response);
},
function(error) {
console.log(error);
}
);