2 var File = imports.File.File;
11 var home = GLib.get_home_dir();
13 var flines = File.read( home + '/.gitlog' + date.format('/Y/m/d') + '.log').split("\n");
14 // first just convert them..
15 // we had an old bug that did not put line breaks in there..
16 // however 00:00:00: is pretty distinct, so let'st try and split on it..
21 for (var i = 0; i < flines.length; i++) {
22 var xl = flines[i].split(/([0-9]{2}:[0-9]{2}:[0-9]{2})/);
23 //print(JSON.stringify(xl));
24 for (var ii=1; ii< xl.length; ii+=2) {
26 lines.push( this.parseLine(xl[ii] + ' ' + xl[ii+1]));
28 lines[p-1].span = lines[p].start - lines[p-1].start; // should be seconds..?
37 for (var i = 0; i < lines.length; i++) {
39 var hour = hours[line].start.format('H');
40 hours[hour] = (typeof(hours[hour]) == 'undefined') ? {} : hours[hour];
41 hours[hour][project] = (typeof(hours[project]) == 'undefined') ?
42 { total : 0, items : [] }
44 hours[hour][project].total += line.span;
45 hours[hour][project].items.push(line);
50 parseLine : function(l)
52 var ret = { cmd : false, line : l };
53 var ar = l.split(/\s+/);
54 print(JSON.stringify(ar));
56 var time = ar.shift();
59 ret.start = xDate.Date.parseDate(this.date.format('Y-m-d') + ' ' + time, 'Y-m-d H:i:s');
62 while (ret.cmd !== false) {
64 if (ta[0] != '-') { //hopfully withc catch stuff.
69 // just assume it's the last bit..
71 throw "invalid line: " + l;
78 ret.title = ar.join(' ');
79 if (ret.title == 'IDLE') {
86 if (typeof(this[ret.cmd])=='undefined') {
87 throw "Unknown application: " + ret.line;
89 if (typeof(this[ret.cmd])=='string') {
90 ret.project = this[ret.cmd]
101 '/usr/bin/perl' : function(ret) {
102 if (ret.title.match(/^PAC/)) {
103 ret.project = 'Unknown';
106 throw "Unknown match: " + ret.line;
108 '/usr/lib/icedove/icedove-bin' : 'Checking Mail',
109 '/usr/lib/chromium/chromium' : function (ret) {
113 case (ret.title.match(/Media Clipping Portal/)):
114 ret.project = 'Media Outreach';
118 ret.project = 'Browsing';
123 '/usr/lib/Komodo-Edit-7/lib/mozilla/komodo' : function(ret) {
124 var l = ret.title.match(/Project\s+(^\)+)/);
127 throw "Unknown match: " + ret.line;
129 'guake' : 'Local Terminal',
134 var res = GitLogParser.parse(xDate.Date.parseDate('2012-07-31', 'Y-m-d'));
135 print(JSON.stringify(res,null,4));
141 // summarize each hour
143 //convert line into 'Project / filename'