Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

{notify => message}

  • Loading branch information...
commit 4aa25fe97e27d66184cdd0bbf1237666ef0fd3a4 1 parent 354c463
Stan Angeloff authored
4 Lottefile
@@ -2,6 +2,6 @@ path = 'test'
2 2 include = '**/test_*.coffee'
3 3 timeout = 5000
4 4
5   -on('hello', function(message, resume) {
6   - resume(message + '!');
  5 +on('hello', function(value, resume) {
  6 + resume(value + '!');
7 7 });
2  bin/cli.js
@@ -126,7 +126,7 @@ function load(options, file, block) {
126 126 for (i = 0; i < symbols.length; i ++) {
127 127 context[symbols[i]] = global[symbols[i]];
128 128 }
129   - symbols = ['on', 'once', 'off', 'notify'];
  129 + symbols = ['on', 'once', 'off', 'message'];
130 130 for (i = 0; i < symbols.length; i ++) {
131 131 context[symbols[i]] = events[symbols[i]];
132 132 }
10 lib/events.js
@@ -27,7 +27,7 @@ function off(event/*, ...listener */) {
27 27 }
28 28 };
29 29
30   -function notify(event, args, resume) {
  30 +function message(event, args, resume) {
31 31 var pending = emitter.listeners(event).length;
32 32 var complete = function() {
33 33 pending = pending - 1;
@@ -49,7 +49,7 @@ function notify(event, args, resume) {
49 49
50 50 emitter.setMaxListeners(0);
51 51
52   -exports.on = on;
53   -exports.once = once;
54   -exports.off = off;
55   -exports.notify = notify;
  52 +exports.on = on;
  53 +exports.once = once;
  54 +exports.off = off;
  55 +exports.message = message;
4 lib/inject/main.js
@@ -82,7 +82,7 @@ this.open = function open(uri, message, options, block) {
82 82 _waiting = _waiting + 1;
83 83 };
84 84
85   -this.notify = function notify(/* event, ...args, resume */) {
  85 +this.message = function message(/* event, ...args, resume */) {
86 86 var args = Array.prototype.slice.call(arguments),
87 87 event = args.shift(),
88 88 resume = (typeof (args[args.length - 1]) === 'function' ? args.pop() : null);
@@ -104,7 +104,7 @@ this.notify = function notify(/* event, ...args, resume */) {
104 104 complete();
105 105 }
106 106 };
107   - request.open('POST', ${SERVER:encode} + '/notify/' + encodeURIComponent(event), true);
  107 + request.open('POST', ${SERVER:encode} + '/message/' + encodeURIComponent(event), true);
108 108 request.setRequestHeader('Content-Type', 'application/json');
109 109 request.send(JSON.stringify(args));
110 110 };
6 lib/inject/test/page.js
@@ -15,7 +15,7 @@ TestPage.prototype.base = this.base;
15 15 TestPage.prototype.absolute = this.absolute;
16 16 TestPage.prototype.open = this.open;
17 17
18   -var _notify = this.notify;
  18 +var _message = this.message;
19 19
20 20 TestPage.prototype.group = function TestPage_group(name, block) {
21 21 var child = new TestGroup(name, this);
@@ -102,13 +102,13 @@ TestPage.prototype.using = function TestPage_using(object, block) {
102 102 ';
103 103 };
104 104
105   -TestPage.prototype.notify = function TestPage_notify() {
  105 +TestPage.prototype.message = function TestPage_message() {
106 106 var args = Array.prototype.slice.call(arguments),
107 107 resume = args[args.length - 1];
108 108 if (typeof (resume) === 'function') {
109 109 args[args.length - 1] = this.bind(resume);
110 110 }
111   - return _notify.apply(this, args);
  111 + return _message.apply(this, args);
112 112 };
113 113
114 114 TestPage.prototype._defineGetters = function TestPage_defineGetters() {
6 lib/server.js
@@ -21,9 +21,9 @@ function listen(port, address) {
21 21 });
22 22 if (body.length) {
23 23 var json = JSON.parse(body),
24   - route = /^\/(notify)\/([\w\-]+)$/.exec(request.url);
25   - if (route && route[1] === 'notify' && route[2]) {
26   - events.notify(route[2], json, function() {
  24 + route = /^\/(message)\/([\w\-]+)$/.exec(request.url);
  25 + if (route && route[1] === 'message' && route[2]) {
  26 + events.message(route[2], json, function() {
27 27 response.end(JSON.stringify(Array.prototype.slice.call(arguments)));
28 28 });
29 29 } else {
8 test/test_message.coffee
... ... @@ -0,0 +1,8 @@
  1 +@base 'http://' + phantom.args[0] + ':' + phantom.args[1]
  2 +@title 'localhost.localdomain'
  3 +
  4 +@open '/', 'message(..)', ->
  5 + @describe 'should message server using events', ->
  6 + @message 'hello', value = 'World', (response) ->
  7 + @assert.equal response, "#{value}!"
  8 + @success()
8 test/test_notify.coffee
... ... @@ -1,8 +0,0 @@
1   -@base 'http://' + phantom.args[0] + ':' + phantom.args[1]
2   -@title 'localhost.localdomain'
3   -
4   -@open '/', 'notify(..)', ->
5   - @describe 'should notify server using events', ->
6   - @notify 'hello', message = 'World', (response) ->
7   - @assert.equal response, "#{message}!"
8   - @success()

0 comments on commit 4aa25fe

Please sign in to comment.
Something went wrong with that request. Please try again.