Skip to content

Commit

Permalink
Remove coffeescript.
Browse files Browse the repository at this point in the history
  • Loading branch information
oremj committed Feb 23, 2013
1 parent ae0fd67 commit 7230a34
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 72 deletions.
33 changes: 0 additions & 33 deletions captain.coffee

This file was deleted.

80 changes: 43 additions & 37 deletions captain.js
@@ -1,44 +1,50 @@
// Generated by CoffeeScript 1.3.1
var SUBTASK_RE, TASK_RE;
var TASK_RE = /^\[(.+?)] (Finished|Running) (.*)/;
var SUBTASK_RE = /^\[(.+?)\] \[(.+?)\] (\w+):\s*(.*)$/;

TASK_RE = /^\[(.+?)] (Finished|Running) (.*)/;
function parse_task(task_m, state) {
var date=task_m[1], stat=task_m[2], task=task_m[3];
if(stat == "Running"){
state.task = [date, task];
} else if(stat == "Finished") {
state.completed.push(task.match(/(.+?) \(([\d\.]+)s\)/).slice(1));
}
}

SUBTASK_RE = /^\[(.+?)\] \[(.+?)\] (\w+):\s*(.*)$/;
function parse_subtask(subtask_m, state) {
var date = subtask_m[1],
host = subtask_m[2],
kind = subtask_m[3],
text = subtask_m[4];
if(kind == "running") {
state.queue[host] = text;
} else if(kind == "finished") {
var res = text.match(/^(.*)\s+\((.*)\)$/);
if(state.queue[host] == res[1]) {
delete state.queue[host];
}
} else if(kind == "failed") {
state["failed"].push(state.task[0], state.task[1], host, task);
}
}

exports.parselog = function(stream) {
var date, host, kind, line, msg, state, status, task, text, time, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
state = {
task: "",
queue: {},
failed: [],
completed: []
};
_ref = stream.split("\n");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
line = _ref[_i];
if (TASK_RE.test(line)) {
_ref1 = TASK_RE.exec(line).slice(1), date = _ref1[0], status = _ref1[1], task = _ref1[2];
if (status === "Running") {
state.task = [date, task];
} else if (status === "Finished") {
_ref2 = /^(.+?) \(([\d\.]+)s\)/.exec(task).slice(1), task = _ref2[0], time = _ref2[1];
state.completed.push([task, time]);
}
state.task = [date, task];
} else if (SUBTASK_RE.test(line)) {
_ref3 = SUBTASK_RE.exec(line).slice(1), date = _ref3[0], host = _ref3[1], kind = _ref3[2], text = _ref3[3];
if (kind === "running") {
state.queue[host] = text;
} else if (kind === "finished") {
_ref4 = /^(.*)\s+\((.*)\)$/.exec(text).slice(1), msg = _ref4[0], time = _ref4[1];
if (state.queue[host] === msg) {
delete state.queue[host];
state = {
task: "",
queue: {},
failed: [],
completed: []
};
var lines = stream.split("\n");
for(var i=0; i < lines.length; i++) {
var line = lines[i];

var task_m = line.match(TASK_RE);
var subtask_m = line.match(SUBTASK_RE);
if(task_m) {
parse_task(task_m, state);
} else if(subtask_m) {
parse_subtask(subtask_m, state);
}
} else if (kind === "failed") {
_ref5 = state.task, date = _ref5[0], task = _ref5[1];
state["failed"].push([date, task, host, text]);
}
}
}
return state;
return state;
};
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "pushbots",
"description": "IRC bots to go with Chief/Freddo",
"version": "0.1.6",
"version": "0.1.7",
"author": "Jeff Balogh <jbalogh@mozilla.com>",
"contributors": [
"James Socol <james@mozilla.com>",
Expand Down
4 changes: 3 additions & 1 deletion pushbot.js
Expand Up @@ -148,7 +148,9 @@ function botFactory(options) {
// to pick up new completed tasks.
var check = function() {
request(path, function(err, response, body) {
update(parselog(body));
if(body) {
update(parselog(body));
}
if (timeToDie) {
clearInterval(interval);
oldStatus = newStatus = {};
Expand Down

0 comments on commit 7230a34

Please sign in to comment.