Comparing version 0.2.1 to 0.2.2
var http = require('http') | ||
, events = require('../services/event_manager') | ||
, notify = require('../services/notifier') | ||
, growl_enabled = false; | ||
, notify = require('../services/notifier'); | ||
@@ -16,15 +15,18 @@ exports.requestHandler = function(req, res) { | ||
body = body ? JSON.parse(body) : {}; | ||
if (req.method === 'GET') { | ||
// Block on event | ||
event = events.find(body.event); | ||
} else if (req.method === 'POST') { | ||
// Announce status of event | ||
event = events.add(body); | ||
notify.event(body); | ||
} else if (req.method === 'DELETE') { | ||
// Flush events | ||
events.clear(); | ||
notify.flush(); | ||
res.writeHead(204); | ||
return res.end(); | ||
switch(req.method) { | ||
case 'GET': // Flinch on | ||
event = events.find(body.event); | ||
break; | ||
case 'POST': // Flinch at OR Flinch gg | ||
event = events.add(body); | ||
notify.event(body); | ||
break; | ||
case 'DELETE': // Flinch flush | ||
events.clear(); | ||
notify.flush(); | ||
res.writeHead(204); | ||
return res.end(); | ||
default: // Bad request | ||
res.writeHead(400); | ||
return res.end(); | ||
} | ||
@@ -31,0 +33,0 @@ res.writeHead(200, {'Content-Type': 'text/json'}); |
{ | ||
"name": "flinch", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Multitask with cat-like reflexes", | ||
@@ -5,0 +5,0 @@ "author": "Bilal Quadri", |
@@ -45,3 +45,3 @@ flinch | ||
server start a flinch server | ||
server [options] start a flinch server | ||
s alias for server command | ||
@@ -60,7 +60,7 @@ on <event> block on the specified event | ||
Option for server command: | ||
Options for server command: | ||
-g, --growl enable growl notifications | ||
Option for gg and at commands: | ||
Options for gg and at commands: | ||
@@ -67,0 +67,0 @@ -t, --ttl [ttl] set time to live for event success announcement in minutes |
@@ -111,2 +111,14 @@ var http = require('http') | ||
}); | ||
it('responds with 400 on a PUT request', function(done) { | ||
reqStub.method = 'PUT'; | ||
stub_request_body(); | ||
mute(); | ||
server.requestHandler(reqStub, resSpy); | ||
unmute(); | ||
resSpy.writeHead.should.have.been.calledWith(400); | ||
resSpy.end.should.have.been.called; | ||
done(); | ||
}); | ||
}); | ||
@@ -117,3 +129,3 @@ | ||
mute(); | ||
server.start.call({port: 5000}); | ||
server.start.call({ port: 5000 }); | ||
listenSpy.should.have.been.calledWith(5000); | ||
@@ -123,4 +135,12 @@ unmute(); | ||
}); | ||
it('enables growl notifications if options say to', function(done) { | ||
var notifyMock = sinon.mock(notify); | ||
notifyMock.expects('set_growl_support').withArgs(true).once(); | ||
server.start.call({ port: 5000 }, { growl: true }); | ||
notifyMock.verify(); | ||
done(); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38789
957