hookly 0.9.0 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/circle.yml +3 -0
- data/lib/hookly/version.rb +1 -1
- data/spec/lib/request_spec.rb +1 -1
- data/vendor/assets/javascripts/hookly.js +191 -192
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b1c6a8c96900792edf0f88eedff82ed285e5b3e
|
4
|
+
data.tar.gz: 881fbe2841f6b04b9f536945c2ca0cbe28d1c2bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5440266294ac5618862dbfaad96c16fe9c9105641a5fa942ec48d49194e9f843a3524951ab9e8e13d96baddcc0b41b5b02f538d4b080d88be4854f214afb10e9
|
7
|
+
data.tar.gz: 97459b12480916ec0cbe24674e35e919bb6fb40f824fd0d648ca8c6081bacaed340658cd35b52b524b8f659c2b4d1d079498c57f662d184b991511d225d79e09
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
#hookly-rails
|
2
2
|
|
3
|
+
[![Circle CI](https://circleci.com/gh/bnorton/hookly-rails.svg?style=svg)](https://circleci.com/gh/bnorton/hookly-rails)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/hookly.svg)](http://badge.fury.io/rb/hookly)
|
5
|
+
|
3
6
|
1. Ruby wrapper for the Hookly API
|
4
7
|
2. hookly.js asset pipeline provider/wrapper
|
5
8
|
|
@@ -40,9 +43,9 @@ hookly.on('#updates', function(options) {
|
|
40
43
|
});
|
41
44
|
```
|
42
45
|
|
43
|
-
|
46
|
+
Push a new message the updates channel
|
44
47
|
```ruby
|
45
|
-
Hookly::
|
48
|
+
Hookly::Message.create('#updates', model: 'Message', id: 5, text: 'Thanks for the info.')
|
46
49
|
#=> #<Hookly::Message id: '44fjwq-djas' slug: '#updates', data: { model: 'Message', id: 5, text: 'Thanks for the info.' }>
|
47
50
|
```
|
48
51
|
|
@@ -60,7 +63,7 @@ hookly.on('#updates', function(options) {
|
|
60
63
|
```
|
61
64
|
|
62
65
|
```ruby
|
63
|
-
Hookly::
|
66
|
+
Hookly::Message.create('#updates', '{{uid}}', id: 6, text: 'Thanks for the PRIVATE info.')
|
64
67
|
#=> #<Hookly::Message id: '44fjwq-djas' slug: '#updates', uid: '{{uid}}' data: { model: 'Message', id: 6, text: 'Thanks for the PRIVATE info.' }>
|
65
68
|
```
|
66
69
|
|
data/circle.yml
ADDED
data/lib/hookly/version.rb
CHANGED
data/spec/lib/request_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Hookly::Request do
|
|
8
8
|
let(:run) { described_class.run(method, 'pathname', options, body) }
|
9
9
|
|
10
10
|
let!(:request) { double(:request, :run => response) }
|
11
|
-
let!(:response) { double(:response, :success? => true, :response_body => { response: 'body' }.to_json, :response_code => 900) }
|
11
|
+
let!(:response) { double(:response, :success? => true, :response_body => { code: 10, message: { response: 'body' } }.to_json, :response_code => 900) }
|
12
12
|
|
13
13
|
before do
|
14
14
|
allow(Typhoeus::Request).to receive(:new).and_return(request)
|
@@ -3,10 +3,149 @@
|
|
3
3
|
* This library may be freely distributed under the MIT license.
|
4
4
|
*/
|
5
5
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.hookly = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
6
|
+
var hookly = {},
|
7
|
+
defaults,
|
8
|
+
channels,
|
9
|
+
connections,
|
10
|
+
clone = function(obj) {
|
11
|
+
return JSON.parse(JSON.stringify(obj));
|
12
|
+
};
|
13
|
+
|
14
|
+
hookly.reset = function() {
|
15
|
+
delete hookly.token;
|
16
|
+
delete hookly.uid;
|
17
|
+
delete hookly.adapter;
|
18
|
+
|
19
|
+
defaults = {};
|
20
|
+
channels = {};
|
21
|
+
connections = {};
|
22
|
+
|
23
|
+
return hookly;
|
24
|
+
};
|
25
|
+
|
26
|
+
hookly.start = function(token, uid, url) {
|
27
|
+
hookly.token = token;
|
28
|
+
hookly.uid = uid;
|
29
|
+
hookly.url = url || 'https://hookly.herokuapp.com';
|
30
|
+
|
31
|
+
defaults.token = token;
|
32
|
+
hookly.uid && (defaults.uid = uid);
|
33
|
+
|
34
|
+
hookly.adapter = new hookly.Adapter(hookly.url);
|
35
|
+
hookly.adapter.connect(defaults);
|
36
|
+
};
|
37
|
+
|
38
|
+
hookly.on = function(channel, callback) {
|
39
|
+
channels[channel] || (channels[channel] = []);
|
40
|
+
channels[channel].push(callback);
|
41
|
+
|
42
|
+
var opts = clone(defaults);
|
43
|
+
opts.slug = channel;
|
44
|
+
|
45
|
+
hookly.adapter.channel(opts);
|
46
|
+
};
|
47
|
+
|
48
|
+
hookly.notify = function(channel, uid, options) {
|
49
|
+
if(!options) {
|
50
|
+
options = uid;
|
51
|
+
uid = null;
|
52
|
+
}
|
53
|
+
|
54
|
+
var opts = clone(defaults);
|
55
|
+
opts.to = { slug: channel };
|
56
|
+
opts.body = options;
|
57
|
+
|
58
|
+
uid && (opts.to.uid = uid);
|
59
|
+
|
60
|
+
hookly.adapter.send(opts);
|
61
|
+
};
|
62
|
+
|
63
|
+
/*
|
64
|
+
* Adapter
|
65
|
+
* Connect to and translate data into the the communication layer.
|
66
|
+
*/
|
67
|
+
|
68
|
+
hookly.Adapter = function(url) {
|
69
|
+
var that = {
|
70
|
+
url: url,
|
71
|
+
io: require('socket.io-client'),
|
72
|
+
initialized: false,
|
73
|
+
connected: false
|
74
|
+
}, sendQueue = [];
|
75
|
+
|
76
|
+
that.socket = that.io(that.url);
|
77
|
+
|
78
|
+
that.connect = function(options) {
|
79
|
+
if(that.initialized) {
|
80
|
+
console.warn('You only need to connect once');
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
|
84
|
+
that.initialized = true;
|
85
|
+
that.options = options;
|
86
|
+
|
87
|
+
that.socket.on('connect', function() {
|
88
|
+
that.connected = true;
|
89
|
+
that.socket.emit('connections:create', JSON.stringify(that.options));
|
90
|
+
|
91
|
+
for(var key in connections) {
|
92
|
+
that.socket.emit('connections:update', JSON.stringify(connections[key]));
|
93
|
+
}
|
94
|
+
|
95
|
+
flushSendQueue();
|
96
|
+
});
|
97
|
+
|
98
|
+
that.socket.on('disconnect', function() {
|
99
|
+
that.connected = false;
|
100
|
+
});
|
101
|
+
|
102
|
+
that.socket.on('message', that.call);
|
103
|
+
};
|
104
|
+
|
105
|
+
that.channel = function(options) { var channel;
|
106
|
+
if(connections[(channel = options.slug)])
|
107
|
+
return;
|
108
|
+
|
109
|
+
connections[channel] = options;
|
110
|
+
|
111
|
+
that.socket.emit('connections:update', JSON.stringify(options));
|
112
|
+
};
|
113
|
+
|
114
|
+
that.call = function(data) {
|
115
|
+
data = JSON.parse(data);
|
116
|
+
|
117
|
+
var fns = channels[data.slug] || [];
|
118
|
+
for(var i=fns.length-1; i>=0; --i) {
|
119
|
+
fns[i].call(hookly , clone(data.body), { kind: data.kind });
|
120
|
+
}
|
121
|
+
};
|
122
|
+
|
123
|
+
that.send = function(options) {
|
124
|
+
sendQueue.push(options);
|
125
|
+
|
126
|
+
if(that.connected) {
|
127
|
+
flushSendQueue();
|
128
|
+
}
|
129
|
+
};
|
130
|
+
|
131
|
+
return that;
|
132
|
+
|
133
|
+
function flushSendQueue() {
|
134
|
+
for(var i=0; i<sendQueue.length; ++i) {
|
135
|
+
that.socket.emit('notes:create', JSON.stringify(sendQueue[i]));
|
136
|
+
}
|
137
|
+
|
138
|
+
sendQueue = [];
|
139
|
+
}
|
140
|
+
};
|
141
|
+
|
142
|
+
exports = module.exports = hookly.reset();
|
143
|
+
|
144
|
+
},{"socket.io-client":2}],2:[function(require,module,exports){
|
6
145
|
|
7
146
|
module.exports = require('./lib/');
|
8
147
|
|
9
|
-
},{"./lib/":
|
148
|
+
},{"./lib/":3}],3:[function(require,module,exports){
|
10
149
|
|
11
150
|
/**
|
12
151
|
* Module dependencies.
|
@@ -95,7 +234,7 @@
|
|
95
234
|
exports.Manager = require('./manager');
|
96
235
|
exports.Socket = require('./socket');
|
97
236
|
|
98
|
-
},{"./manager":
|
237
|
+
},{"./manager":4,"./socket":6,"./url":7,"debug":11,"socket.io-parser":47}],4:[function(require,module,exports){
|
99
238
|
|
100
239
|
/**
|
101
240
|
* Module dependencies.
|
@@ -600,7 +739,7 @@
|
|
600
739
|
this.emitAll('reconnect', attempt);
|
601
740
|
};
|
602
741
|
|
603
|
-
},{"./on":
|
742
|
+
},{"./on":5,"./socket":6,"./url":7,"backo2":8,"component-bind":9,"component-emitter":10,"debug":11,"engine.io-client":12,"indexof":43,"object-component":44,"socket.io-parser":47}],5:[function(require,module,exports){
|
604
743
|
|
605
744
|
/**
|
606
745
|
* Module exports.
|
@@ -626,7 +765,7 @@
|
|
626
765
|
};
|
627
766
|
}
|
628
767
|
|
629
|
-
},{}],
|
768
|
+
},{}],6:[function(require,module,exports){
|
630
769
|
|
631
770
|
/**
|
632
771
|
* Module dependencies.
|
@@ -1013,7 +1152,7 @@
|
|
1013
1152
|
return this;
|
1014
1153
|
};
|
1015
1154
|
|
1016
|
-
},{"./on":
|
1155
|
+
},{"./on":5,"component-bind":9,"component-emitter":10,"debug":11,"has-binary":41,"socket.io-parser":47,"to-array":51}],7:[function(require,module,exports){
|
1017
1156
|
(function (global){
|
1018
1157
|
|
1019
1158
|
/**
|
@@ -1090,7 +1229,7 @@
|
|
1090
1229
|
}
|
1091
1230
|
|
1092
1231
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
1093
|
-
},{"debug":
|
1232
|
+
},{"debug":11,"parseuri":45}],8:[function(require,module,exports){
|
1094
1233
|
|
1095
1234
|
/**
|
1096
1235
|
* Expose `Backoff`.
|
@@ -1177,7 +1316,7 @@
|
|
1177
1316
|
};
|
1178
1317
|
|
1179
1318
|
|
1180
|
-
},{}],
|
1319
|
+
},{}],9:[function(require,module,exports){
|
1181
1320
|
/**
|
1182
1321
|
* Slice reference.
|
1183
1322
|
*/
|
@@ -1202,7 +1341,7 @@
|
|
1202
1341
|
}
|
1203
1342
|
};
|
1204
1343
|
|
1205
|
-
},{}],
|
1344
|
+
},{}],10:[function(require,module,exports){
|
1206
1345
|
|
1207
1346
|
/**
|
1208
1347
|
* Expose `Emitter`.
|
@@ -1368,7 +1507,7 @@
|
|
1368
1507
|
return !! this.listeners(event).length;
|
1369
1508
|
};
|
1370
1509
|
|
1371
|
-
},{}],
|
1510
|
+
},{}],11:[function(require,module,exports){
|
1372
1511
|
|
1373
1512
|
/**
|
1374
1513
|
* Expose `debug()` as the module.
|
@@ -1507,11 +1646,11 @@
|
|
1507
1646
|
if (window.localStorage) debug.enable(localStorage.debug);
|
1508
1647
|
} catch(e){}
|
1509
1648
|
|
1510
|
-
},{}],
|
1649
|
+
},{}],12:[function(require,module,exports){
|
1511
1650
|
|
1512
1651
|
module.exports = require('./lib/');
|
1513
1652
|
|
1514
|
-
},{"./lib/":
|
1653
|
+
},{"./lib/":13}],13:[function(require,module,exports){
|
1515
1654
|
|
1516
1655
|
module.exports = require('./socket');
|
1517
1656
|
|
@@ -1523,7 +1662,7 @@
|
|
1523
1662
|
*/
|
1524
1663
|
module.exports.parser = require('engine.io-parser');
|
1525
1664
|
|
1526
|
-
},{"./socket":
|
1665
|
+
},{"./socket":14,"engine.io-parser":26}],14:[function(require,module,exports){
|
1527
1666
|
(function (global){
|
1528
1667
|
/**
|
1529
1668
|
* Module dependencies.
|
@@ -2232,7 +2371,7 @@
|
|
2232
2371
|
};
|
2233
2372
|
|
2234
2373
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
2235
|
-
},{"./transport":
|
2374
|
+
},{"./transport":15,"./transports":16,"component-emitter":10,"debug":23,"engine.io-parser":26,"indexof":43,"parsejson":37,"parseqs":38,"parseuri":39}],15:[function(require,module,exports){
|
2236
2375
|
/**
|
2237
2376
|
* Module dependencies.
|
2238
2377
|
*/
|
@@ -2393,7 +2532,7 @@
|
|
2393
2532
|
this.emit('close');
|
2394
2533
|
};
|
2395
2534
|
|
2396
|
-
},{"component-emitter":
|
2535
|
+
},{"component-emitter":10,"engine.io-parser":26}],16:[function(require,module,exports){
|
2397
2536
|
(function (global){
|
2398
2537
|
/**
|
2399
2538
|
* Module dependencies
|
@@ -2450,7 +2589,7 @@
|
|
2450
2589
|
}
|
2451
2590
|
|
2452
2591
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
2453
|
-
},{"./polling-jsonp":
|
2592
|
+
},{"./polling-jsonp":17,"./polling-xhr":18,"./websocket":20,"xmlhttprequest":21}],17:[function(require,module,exports){
|
2454
2593
|
(function (global){
|
2455
2594
|
|
2456
2595
|
/**
|
@@ -2687,7 +2826,7 @@
|
|
2687
2826
|
};
|
2688
2827
|
|
2689
2828
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
2690
|
-
},{"./polling":
|
2829
|
+
},{"./polling":19,"component-inherit":22}],18:[function(require,module,exports){
|
2691
2830
|
(function (global){
|
2692
2831
|
/**
|
2693
2832
|
* Module requirements.
|
@@ -3075,7 +3214,7 @@
|
|
3075
3214
|
}
|
3076
3215
|
|
3077
3216
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
3078
|
-
},{"./polling":
|
3217
|
+
},{"./polling":19,"component-emitter":10,"component-inherit":22,"debug":23,"xmlhttprequest":21}],19:[function(require,module,exports){
|
3079
3218
|
/**
|
3080
3219
|
* Module dependencies.
|
3081
3220
|
*/
|
@@ -3322,7 +3461,7 @@
|
|
3322
3461
|
return schema + '://' + this.hostname + port + this.path + query;
|
3323
3462
|
};
|
3324
3463
|
|
3325
|
-
},{"../transport":
|
3464
|
+
},{"../transport":15,"component-inherit":22,"debug":23,"engine.io-parser":26,"parseqs":38,"xmlhttprequest":21}],20:[function(require,module,exports){
|
3326
3465
|
/**
|
3327
3466
|
* Module dependencies.
|
3328
3467
|
*/
|
@@ -3562,7 +3701,7 @@
|
|
3562
3701
|
return !!WebSocket && !('__initialize' in WebSocket && this.name === WS.prototype.name);
|
3563
3702
|
};
|
3564
3703
|
|
3565
|
-
},{"../transport":
|
3704
|
+
},{"../transport":15,"component-inherit":22,"debug":23,"engine.io-parser":26,"parseqs":38,"ws":40}],21:[function(require,module,exports){
|
3566
3705
|
// browser shim for xmlhttprequest module
|
3567
3706
|
var hasCORS = require('has-cors');
|
3568
3707
|
|
@@ -3600,7 +3739,7 @@
|
|
3600
3739
|
}
|
3601
3740
|
}
|
3602
3741
|
|
3603
|
-
},{"has-cors":
|
3742
|
+
},{"has-cors":35}],22:[function(require,module,exports){
|
3604
3743
|
|
3605
3744
|
module.exports = function(a, b){
|
3606
3745
|
var fn = function(){};
|
@@ -3608,7 +3747,7 @@
|
|
3608
3747
|
a.prototype = new fn;
|
3609
3748
|
a.prototype.constructor = a;
|
3610
3749
|
};
|
3611
|
-
},{}],
|
3750
|
+
},{}],23:[function(require,module,exports){
|
3612
3751
|
|
3613
3752
|
/**
|
3614
3753
|
* This is the web browser implementation of `debug()`.
|
@@ -3757,7 +3896,7 @@
|
|
3757
3896
|
|
3758
3897
|
exports.enable(load());
|
3759
3898
|
|
3760
|
-
},{"./debug":
|
3899
|
+
},{"./debug":24}],24:[function(require,module,exports){
|
3761
3900
|
|
3762
3901
|
/**
|
3763
3902
|
* This is the common logic for both the Node.js and web browser
|
@@ -3956,7 +4095,7 @@
|
|
3956
4095
|
return val;
|
3957
4096
|
}
|
3958
4097
|
|
3959
|
-
},{"ms":
|
4098
|
+
},{"ms":25}],25:[function(require,module,exports){
|
3960
4099
|
/**
|
3961
4100
|
* Helpers.
|
3962
4101
|
*/
|
@@ -4069,7 +4208,7 @@
|
|
4069
4208
|
return Math.ceil(ms / n) + ' ' + name + 's';
|
4070
4209
|
}
|
4071
4210
|
|
4072
|
-
},{}],
|
4211
|
+
},{}],26:[function(require,module,exports){
|
4073
4212
|
(function (global){
|
4074
4213
|
/**
|
4075
4214
|
* Module dependencies.
|
@@ -4667,7 +4806,7 @@
|
|
4667
4806
|
};
|
4668
4807
|
|
4669
4808
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
4670
|
-
},{"./keys":
|
4809
|
+
},{"./keys":27,"after":28,"arraybuffer.slice":29,"base64-arraybuffer":30,"blob":31,"has-binary":32,"utf8":34}],27:[function(require,module,exports){
|
4671
4810
|
|
4672
4811
|
/**
|
4673
4812
|
* Gets the keys for an object.
|
@@ -4688,7 +4827,7 @@
|
|
4688
4827
|
return arr;
|
4689
4828
|
};
|
4690
4829
|
|
4691
|
-
},{}],
|
4830
|
+
},{}],28:[function(require,module,exports){
|
4692
4831
|
module.exports = after
|
4693
4832
|
|
4694
4833
|
function after(count, callback, err_cb) {
|
@@ -4718,7 +4857,7 @@
|
|
4718
4857
|
|
4719
4858
|
function noop() {}
|
4720
4859
|
|
4721
|
-
},{}],
|
4860
|
+
},{}],29:[function(require,module,exports){
|
4722
4861
|
/**
|
4723
4862
|
* An abstraction for slicing an arraybuffer even when
|
4724
4863
|
* ArrayBuffer.prototype.slice is not supported
|
@@ -4749,7 +4888,7 @@
|
|
4749
4888
|
return result.buffer;
|
4750
4889
|
};
|
4751
4890
|
|
4752
|
-
},{}],
|
4891
|
+
},{}],30:[function(require,module,exports){
|
4753
4892
|
/*
|
4754
4893
|
* base64-arraybuffer
|
4755
4894
|
* https://github.com/niklasvh/base64-arraybuffer
|
@@ -4810,7 +4949,7 @@
|
|
4810
4949
|
};
|
4811
4950
|
})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
|
4812
4951
|
|
4813
|
-
},{}],
|
4952
|
+
},{}],31:[function(require,module,exports){
|
4814
4953
|
(function (global){
|
4815
4954
|
/**
|
4816
4955
|
* Create a blob builder even when vendor prefixes exist
|
@@ -4863,7 +5002,7 @@
|
|
4863
5002
|
})();
|
4864
5003
|
|
4865
5004
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
4866
|
-
},{}],
|
5005
|
+
},{}],32:[function(require,module,exports){
|
4867
5006
|
(function (global){
|
4868
5007
|
|
4869
5008
|
/*
|
@@ -4925,12 +5064,12 @@
|
|
4925
5064
|
}
|
4926
5065
|
|
4927
5066
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
4928
|
-
},{"isarray":
|
5067
|
+
},{"isarray":33}],33:[function(require,module,exports){
|
4929
5068
|
module.exports = Array.isArray || function (arr) {
|
4930
5069
|
return Object.prototype.toString.call(arr) == '[object Array]';
|
4931
5070
|
};
|
4932
5071
|
|
4933
|
-
},{}],
|
5072
|
+
},{}],34:[function(require,module,exports){
|
4934
5073
|
(function (global){
|
4935
5074
|
/*! http://mths.be/utf8js v2.0.0 by @mathias */
|
4936
5075
|
;(function(root) {
|
@@ -5173,7 +5312,7 @@
|
|
5173
5312
|
}(this));
|
5174
5313
|
|
5175
5314
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
5176
|
-
},{}],
|
5315
|
+
},{}],35:[function(require,module,exports){
|
5177
5316
|
|
5178
5317
|
/**
|
5179
5318
|
* Module dependencies.
|
@@ -5198,7 +5337,7 @@
|
|
5198
5337
|
module.exports = false;
|
5199
5338
|
}
|
5200
5339
|
|
5201
|
-
},{"global":
|
5340
|
+
},{"global":36}],36:[function(require,module,exports){
|
5202
5341
|
|
5203
5342
|
/**
|
5204
5343
|
* Returns `this`. Execute this without a "context" (i.e. without it being
|
@@ -5208,7 +5347,7 @@
|
|
5208
5347
|
|
5209
5348
|
module.exports = (function () { return this; })();
|
5210
5349
|
|
5211
|
-
},{}],
|
5350
|
+
},{}],37:[function(require,module,exports){
|
5212
5351
|
(function (global){
|
5213
5352
|
/**
|
5214
5353
|
* JSON parse.
|
@@ -5243,7 +5382,7 @@
|
|
5243
5382
|
}
|
5244
5383
|
};
|
5245
5384
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
5246
|
-
},{}],
|
5385
|
+
},{}],38:[function(require,module,exports){
|
5247
5386
|
/**
|
5248
5387
|
* Compiles a querystring
|
5249
5388
|
* Returns string representation of the object
|
@@ -5282,7 +5421,7 @@
|
|
5282
5421
|
return qry;
|
5283
5422
|
};
|
5284
5423
|
|
5285
|
-
},{}],
|
5424
|
+
},{}],39:[function(require,module,exports){
|
5286
5425
|
/**
|
5287
5426
|
* Parses an URI
|
5288
5427
|
*
|
@@ -5323,7 +5462,7 @@
|
|
5323
5462
|
return uri;
|
5324
5463
|
};
|
5325
5464
|
|
5326
|
-
},{}],
|
5465
|
+
},{}],40:[function(require,module,exports){
|
5327
5466
|
|
5328
5467
|
/**
|
5329
5468
|
* Module dependencies.
|
@@ -5368,7 +5507,7 @@
|
|
5368
5507
|
|
5369
5508
|
if (WebSocket) ws.prototype = WebSocket.prototype;
|
5370
5509
|
|
5371
|
-
},{}],
|
5510
|
+
},{}],41:[function(require,module,exports){
|
5372
5511
|
(function (global){
|
5373
5512
|
|
5374
5513
|
/*
|
@@ -5430,9 +5569,9 @@
|
|
5430
5569
|
}
|
5431
5570
|
|
5432
5571
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
5433
|
-
},{"isarray":
|
5434
|
-
arguments[4][
|
5435
|
-
},{"dup":
|
5572
|
+
},{"isarray":42}],42:[function(require,module,exports){
|
5573
|
+
arguments[4][33][0].apply(exports,arguments)
|
5574
|
+
},{"dup":33}],43:[function(require,module,exports){
|
5436
5575
|
|
5437
5576
|
var indexOf = [].indexOf;
|
5438
5577
|
|
@@ -5443,7 +5582,7 @@
|
|
5443
5582
|
}
|
5444
5583
|
return -1;
|
5445
5584
|
};
|
5446
|
-
},{}],
|
5585
|
+
},{}],44:[function(require,module,exports){
|
5447
5586
|
|
5448
5587
|
/**
|
5449
5588
|
* HOP ref.
|
@@ -5528,7 +5667,7 @@
|
|
5528
5667
|
exports.isEmpty = function(obj){
|
5529
5668
|
return 0 == exports.length(obj);
|
5530
5669
|
};
|
5531
|
-
},{}],
|
5670
|
+
},{}],45:[function(require,module,exports){
|
5532
5671
|
/**
|
5533
5672
|
* Parses an URI
|
5534
5673
|
*
|
@@ -5555,7 +5694,7 @@
|
|
5555
5694
|
return uri;
|
5556
5695
|
};
|
5557
5696
|
|
5558
|
-
},{}],
|
5697
|
+
},{}],46:[function(require,module,exports){
|
5559
5698
|
(function (global){
|
5560
5699
|
/*global Blob,File*/
|
5561
5700
|
|
@@ -5700,7 +5839,7 @@
|
|
5700
5839
|
};
|
5701
5840
|
|
5702
5841
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
5703
|
-
},{"./is-buffer":
|
5842
|
+
},{"./is-buffer":48,"isarray":49}],47:[function(require,module,exports){
|
5704
5843
|
|
5705
5844
|
/**
|
5706
5845
|
* Module dependencies.
|
@@ -6102,7 +6241,7 @@
|
|
6102
6241
|
};
|
6103
6242
|
}
|
6104
6243
|
|
6105
|
-
},{"./binary":
|
6244
|
+
},{"./binary":46,"./is-buffer":48,"component-emitter":10,"debug":11,"isarray":49,"json3":50}],48:[function(require,module,exports){
|
6106
6245
|
(function (global){
|
6107
6246
|
|
6108
6247
|
module.exports = isBuf;
|
@@ -6119,9 +6258,9 @@
|
|
6119
6258
|
}
|
6120
6259
|
|
6121
6260
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
6122
|
-
},{}],
|
6123
|
-
arguments[4][
|
6124
|
-
},{"dup":
|
6261
|
+
},{}],49:[function(require,module,exports){
|
6262
|
+
arguments[4][33][0].apply(exports,arguments)
|
6263
|
+
},{"dup":33}],50:[function(require,module,exports){
|
6125
6264
|
/*! JSON v3.2.6 | http://bestiejs.github.io/json3 | Copyright 2012-2013, Kit Cambridge | http://kit.mit-license.org */
|
6126
6265
|
;(function (window) {
|
6127
6266
|
// Convenience aliases.
|
@@ -6984,7 +7123,7 @@
|
|
6984
7123
|
}
|
6985
7124
|
}(this));
|
6986
7125
|
|
6987
|
-
},{}],
|
7126
|
+
},{}],51:[function(require,module,exports){
|
6988
7127
|
module.exports = toArray
|
6989
7128
|
|
6990
7129
|
function toArray(list, index) {
|
@@ -6999,145 +7138,5 @@
|
|
6999
7138
|
return array
|
7000
7139
|
}
|
7001
7140
|
|
7002
|
-
},{}],
|
7003
|
-
var hookly = {},
|
7004
|
-
defaults,
|
7005
|
-
channels,
|
7006
|
-
connections,
|
7007
|
-
adapter,
|
7008
|
-
clone = function(obj) {
|
7009
|
-
return JSON.parse(JSON.stringify(obj));
|
7010
|
-
};
|
7011
|
-
|
7012
|
-
hookly.reset = function() {
|
7013
|
-
delete hookly.token;
|
7014
|
-
delete hookly.uid;
|
7015
|
-
|
7016
|
-
defaults = {};
|
7017
|
-
channels = {};
|
7018
|
-
connections = {};
|
7019
|
-
adapter = null;
|
7020
|
-
|
7021
|
-
return hookly;
|
7022
|
-
};
|
7023
|
-
|
7024
|
-
hookly.start = function(token, uid, url) {
|
7025
|
-
hookly.token = token;
|
7026
|
-
hookly.uid = uid;
|
7027
|
-
hookly.url = url || 'https://hookly.herokuapp.com';
|
7028
|
-
|
7029
|
-
defaults.token = token;
|
7030
|
-
hookly.uid && (defaults.uid = uid);
|
7031
|
-
|
7032
|
-
adapter = new hookly.Adapter(hookly.url);
|
7033
|
-
adapter.connect(defaults);
|
7034
|
-
};
|
7035
|
-
|
7036
|
-
hookly.on = function(channel, callback) {
|
7037
|
-
channels[channel] || (channels[channel] = []);
|
7038
|
-
channels[channel].push(callback);
|
7039
|
-
|
7040
|
-
var opts = clone(defaults);
|
7041
|
-
opts.slug = channel;
|
7042
|
-
|
7043
|
-
adapter.channel(opts);
|
7044
|
-
};
|
7045
|
-
|
7046
|
-
hookly.notify = function(channel, uid, options) {
|
7047
|
-
if(!options) {
|
7048
|
-
options = uid;
|
7049
|
-
uid = null;
|
7050
|
-
}
|
7051
|
-
|
7052
|
-
var opts = clone(defaults);
|
7053
|
-
opts.to = { slug: channel };
|
7054
|
-
opts.body = options;
|
7055
|
-
|
7056
|
-
uid && (opts.to.uid = uid);
|
7057
|
-
|
7058
|
-
adapter.send(opts);
|
7059
|
-
};
|
7060
|
-
|
7061
|
-
/*
|
7062
|
-
* Adapter
|
7063
|
-
* Connect to and translate data into the the communication layer.
|
7064
|
-
*/
|
7065
|
-
|
7066
|
-
hookly.Adapter = function(url) {
|
7067
|
-
var that = {
|
7068
|
-
url: url,
|
7069
|
-
io: require('socket.io-client'),
|
7070
|
-
initialized: false,
|
7071
|
-
connected: false
|
7072
|
-
}, sendQueue = [];
|
7073
|
-
|
7074
|
-
that.socket = that.io(that.url);
|
7075
|
-
|
7076
|
-
that.connect = function(options) {
|
7077
|
-
if(that.initialized) {
|
7078
|
-
console.warn('You only need to connect once');
|
7079
|
-
return;
|
7080
|
-
}
|
7081
|
-
|
7082
|
-
that.initialized = true;
|
7083
|
-
that.options = options;
|
7084
|
-
|
7085
|
-
that.socket.on('connect', function() {
|
7086
|
-
that.connected = true;
|
7087
|
-
that.socket.emit('connections:create', JSON.stringify(that.options));
|
7088
|
-
|
7089
|
-
for(var key in connections) {
|
7090
|
-
that.socket.emit('connections:update', JSON.stringify(connections[key]));
|
7091
|
-
}
|
7092
|
-
|
7093
|
-
flushSendQueue();
|
7094
|
-
});
|
7095
|
-
|
7096
|
-
that.socket.on('disconnect', function() {
|
7097
|
-
that.connected = false;
|
7098
|
-
});
|
7099
|
-
|
7100
|
-
that.socket.on('message', that.call);
|
7101
|
-
};
|
7102
|
-
|
7103
|
-
that.channel = function(options) { var channel;
|
7104
|
-
if(connections[(channel = options.slug)])
|
7105
|
-
return;
|
7106
|
-
|
7107
|
-
connections[channel] = options;
|
7108
|
-
|
7109
|
-
that.socket.emit('connections:update', JSON.stringify(options));
|
7110
|
-
};
|
7111
|
-
|
7112
|
-
that.call = function(data) {
|
7113
|
-
data = JSON.parse(data);
|
7114
|
-
|
7115
|
-
var fns = channels[data.slug] || [];
|
7116
|
-
for(var i=fns.length-1; i>=0; --i) {
|
7117
|
-
fns[i].call(hookly , clone(data.body), { kind: data.kind });
|
7118
|
-
}
|
7119
|
-
};
|
7120
|
-
|
7121
|
-
that.send = function(options) {
|
7122
|
-
sendQueue.push(options);
|
7123
|
-
|
7124
|
-
if(that.connected) {
|
7125
|
-
flushSendQueue();
|
7126
|
-
}
|
7127
|
-
};
|
7128
|
-
|
7129
|
-
return that;
|
7130
|
-
|
7131
|
-
function flushSendQueue() {
|
7132
|
-
for(var i=0; i<sendQueue.length; ++i) {
|
7133
|
-
that.socket.emit('notes:create', JSON.stringify(sendQueue[i]));
|
7134
|
-
}
|
7135
|
-
|
7136
|
-
sendQueue = [];
|
7137
|
-
}
|
7138
|
-
};
|
7139
|
-
|
7140
|
-
exports = module.exports = hookly.reset();
|
7141
|
-
|
7142
|
-
},{"socket.io-client":1}]},{},[51])(51)
|
7141
|
+
},{}]},{},[1])(1)
|
7143
7142
|
});
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hookly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Norton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- Gemfile
|
65
65
|
- LICENSE.md
|
66
66
|
- README.md
|
67
|
+
- circle.yml
|
67
68
|
- hookly.gemspec
|
68
69
|
- lib/error.rb
|
69
70
|
- lib/errors/response_error.rb
|