node-events-rails 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7f652508ae2b5bddb1d1230d9524426a6818eab5
4
+ data.tar.gz: f4cb9a9717e7dc6106d8d854389c109f014ab345
5
+ SHA512:
6
+ metadata.gz: abb3aad35a7efcd349604e15faa9e7e1d764c1b8614063b3296d4c6ef2d2009db4ecc72ee61cabf64306b55d19d4402cad30c1596642f8e6ea775cb8bcd744b4
7
+ data.tar.gz: 98ca6d79d45ad3bca9fc2c4b4f213ec905a4fb2a5fcf14012ee137fc557d46b053466ec1dfbc6a357eda64726c7043eaa371fde5df79b33c28bd93ba25fc8bed
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # node-events-rails
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/node-events-rails.svg)](https://badge.fury.io/rb/node-events-rails.svg)
4
+
5
+ [Node](http://nodejs.org/) event module for Rails Asset Pipeline.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'node-events-rails'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install node-events-rails
22
+
23
+ ## Usage
24
+
25
+ Require node_events in your application.js:
26
+
27
+ ```js
28
+ //= require node_events
29
+ ```
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/mariopeixoto/node-events-rails/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create a new Pull Request
38
+
39
+ ## Acknowledgements
40
+
41
+ [Node](http://nodejs.org/) by [Joyent, Inc](https://github.com/joyent) licensed under MIT license.
42
+
43
+ Copyright [Mario Peixoto](https://github.com/mariopeixoto), released under the [MIT license](https://github.com/mariopeixoto/node-events-rails/LICENSE).
@@ -0,0 +1,2 @@
1
+ require "node/events/rails/version"
2
+ require "node/events/rails/engine"
@@ -0,0 +1,8 @@
1
+ module Node
2
+ module Events
3
+ module Rails
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module Node
2
+ module Events
3
+ module Rails
4
+ VERSION = "0.0.2"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,308 @@
1
+ !function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.EventEmitter=e()}}(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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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){
2
+ // Copyright Joyent, Inc. and other Node contributors.
3
+ //
4
+ // Permission is hereby granted, free of charge, to any person obtaining a
5
+ // copy of this software and associated documentation files (the
6
+ // "Software"), to deal in the Software without restriction, including
7
+ // without limitation the rights to use, copy, modify, merge, publish,
8
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
9
+ // persons to whom the Software is furnished to do so, subject to the
10
+ // following conditions:
11
+ //
12
+ // The above copyright notice and this permission notice shall be included
13
+ // in all copies or substantial portions of the Software.
14
+ //
15
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
18
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ function EventEmitter() {
24
+ this._events = this._events || {};
25
+ this._maxListeners = this._maxListeners || undefined;
26
+ }
27
+ module.exports = EventEmitter;
28
+
29
+ // Backwards-compat with node 0.10.x
30
+ EventEmitter.EventEmitter = EventEmitter;
31
+
32
+ EventEmitter.prototype._events = undefined;
33
+ EventEmitter.prototype._maxListeners = undefined;
34
+
35
+ // By default EventEmitters will print a warning if more than 10 listeners are
36
+ // added to it. This is a useful default which helps finding memory leaks.
37
+ EventEmitter.defaultMaxListeners = 10;
38
+
39
+ // Obviously not all Emitters should be limited to 10. This function allows
40
+ // that to be increased. Set to zero for unlimited.
41
+ EventEmitter.prototype.setMaxListeners = function(n) {
42
+ if (!isNumber(n) || n < 0 || isNaN(n))
43
+ throw TypeError('n must be a positive number');
44
+ this._maxListeners = n;
45
+ return this;
46
+ };
47
+
48
+ EventEmitter.prototype.emit = function(type) {
49
+ var er, handler, len, args, i, listeners;
50
+
51
+ if (!this._events)
52
+ this._events = {};
53
+
54
+ // If there is no 'error' event listener then throw.
55
+ if (type === 'error') {
56
+ if (!this._events.error ||
57
+ (isObject(this._events.error) && !this._events.error.length)) {
58
+ er = arguments[1];
59
+ if (er instanceof Error) {
60
+ throw er; // Unhandled 'error' event
61
+ } else {
62
+ throw TypeError('Uncaught, unspecified "error" event.');
63
+ }
64
+ return false;
65
+ }
66
+ }
67
+
68
+ handler = this._events[type];
69
+
70
+ if (isUndefined(handler))
71
+ return false;
72
+
73
+ if (isFunction(handler)) {
74
+ switch (arguments.length) {
75
+ // fast cases
76
+ case 1:
77
+ handler.call(this);
78
+ break;
79
+ case 2:
80
+ handler.call(this, arguments[1]);
81
+ break;
82
+ case 3:
83
+ handler.call(this, arguments[1], arguments[2]);
84
+ break;
85
+ // slower
86
+ default:
87
+ len = arguments.length;
88
+ args = new Array(len - 1);
89
+ for (i = 1; i < len; i++)
90
+ args[i - 1] = arguments[i];
91
+ handler.apply(this, args);
92
+ }
93
+ } else if (isObject(handler)) {
94
+ len = arguments.length;
95
+ args = new Array(len - 1);
96
+ for (i = 1; i < len; i++)
97
+ args[i - 1] = arguments[i];
98
+
99
+ listeners = handler.slice();
100
+ len = listeners.length;
101
+ for (i = 0; i < len; i++)
102
+ listeners[i].apply(this, args);
103
+ }
104
+
105
+ return true;
106
+ };
107
+
108
+ EventEmitter.prototype.addListener = function(type, listener) {
109
+ var m;
110
+
111
+ if (!isFunction(listener))
112
+ throw TypeError('listener must be a function');
113
+
114
+ if (!this._events)
115
+ this._events = {};
116
+
117
+ // To avoid recursion in the case that type === "newListener"! Before
118
+ // adding it to the listeners, first emit "newListener".
119
+ if (this._events.newListener)
120
+ this.emit('newListener', type,
121
+ isFunction(listener.listener) ?
122
+ listener.listener : listener);
123
+
124
+ if (!this._events[type])
125
+ // Optimize the case of one listener. Don't need the extra array object.
126
+ this._events[type] = listener;
127
+ else if (isObject(this._events[type]))
128
+ // If we've already got an array, just append.
129
+ this._events[type].push(listener);
130
+ else
131
+ // Adding the second element, need to change to array.
132
+ this._events[type] = [this._events[type], listener];
133
+
134
+ // Check for listener leak
135
+ if (isObject(this._events[type]) && !this._events[type].warned) {
136
+ var m;
137
+ if (!isUndefined(this._maxListeners)) {
138
+ m = this._maxListeners;
139
+ } else {
140
+ m = EventEmitter.defaultMaxListeners;
141
+ }
142
+
143
+ if (m && m > 0 && this._events[type].length > m) {
144
+ this._events[type].warned = true;
145
+ console.error('(node) warning: possible EventEmitter memory ' +
146
+ 'leak detected. %d listeners added. ' +
147
+ 'Use emitter.setMaxListeners() to increase limit.',
148
+ this._events[type].length);
149
+ if (typeof console.trace === 'function') {
150
+ // not supported in IE 10
151
+ console.trace();
152
+ }
153
+ }
154
+ }
155
+
156
+ return this;
157
+ };
158
+
159
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
160
+
161
+ EventEmitter.prototype.once = function(type, listener) {
162
+ if (!isFunction(listener))
163
+ throw TypeError('listener must be a function');
164
+
165
+ var fired = false;
166
+
167
+ function g() {
168
+ this.removeListener(type, g);
169
+
170
+ if (!fired) {
171
+ fired = true;
172
+ listener.apply(this, arguments);
173
+ }
174
+ }
175
+
176
+ g.listener = listener;
177
+ this.on(type, g);
178
+
179
+ return this;
180
+ };
181
+
182
+ // emits a 'removeListener' event iff the listener was removed
183
+ EventEmitter.prototype.removeListener = function(type, listener) {
184
+ var list, position, length, i;
185
+
186
+ if (!isFunction(listener))
187
+ throw TypeError('listener must be a function');
188
+
189
+ if (!this._events || !this._events[type])
190
+ return this;
191
+
192
+ list = this._events[type];
193
+ length = list.length;
194
+ position = -1;
195
+
196
+ if (list === listener ||
197
+ (isFunction(list.listener) && list.listener === listener)) {
198
+ delete this._events[type];
199
+ if (this._events.removeListener)
200
+ this.emit('removeListener', type, listener);
201
+
202
+ } else if (isObject(list)) {
203
+ for (i = length; i-- > 0;) {
204
+ if (list[i] === listener ||
205
+ (list[i].listener && list[i].listener === listener)) {
206
+ position = i;
207
+ break;
208
+ }
209
+ }
210
+
211
+ if (position < 0)
212
+ return this;
213
+
214
+ if (list.length === 1) {
215
+ list.length = 0;
216
+ delete this._events[type];
217
+ } else {
218
+ list.splice(position, 1);
219
+ }
220
+
221
+ if (this._events.removeListener)
222
+ this.emit('removeListener', type, listener);
223
+ }
224
+
225
+ return this;
226
+ };
227
+
228
+ EventEmitter.prototype.removeAllListeners = function(type) {
229
+ var key, listeners;
230
+
231
+ if (!this._events)
232
+ return this;
233
+
234
+ // not listening for removeListener, no need to emit
235
+ if (!this._events.removeListener) {
236
+ if (arguments.length === 0)
237
+ this._events = {};
238
+ else if (this._events[type])
239
+ delete this._events[type];
240
+ return this;
241
+ }
242
+
243
+ // emit removeListener for all listeners on all events
244
+ if (arguments.length === 0) {
245
+ for (key in this._events) {
246
+ if (key === 'removeListener') continue;
247
+ this.removeAllListeners(key);
248
+ }
249
+ this.removeAllListeners('removeListener');
250
+ this._events = {};
251
+ return this;
252
+ }
253
+
254
+ listeners = this._events[type];
255
+
256
+ if (isFunction(listeners)) {
257
+ this.removeListener(type, listeners);
258
+ } else {
259
+ // LIFO order
260
+ while (listeners.length)
261
+ this.removeListener(type, listeners[listeners.length - 1]);
262
+ }
263
+ delete this._events[type];
264
+
265
+ return this;
266
+ };
267
+
268
+ EventEmitter.prototype.listeners = function(type) {
269
+ var ret;
270
+ if (!this._events || !this._events[type])
271
+ ret = [];
272
+ else if (isFunction(this._events[type]))
273
+ ret = [this._events[type]];
274
+ else
275
+ ret = this._events[type].slice();
276
+ return ret;
277
+ };
278
+
279
+ EventEmitter.listenerCount = function(emitter, type) {
280
+ var ret;
281
+ if (!emitter._events || !emitter._events[type])
282
+ ret = 0;
283
+ else if (isFunction(emitter._events[type]))
284
+ ret = 1;
285
+ else
286
+ ret = emitter._events[type].length;
287
+ return ret;
288
+ };
289
+
290
+ function isFunction(arg) {
291
+ return typeof arg === 'function';
292
+ }
293
+
294
+ function isNumber(arg) {
295
+ return typeof arg === 'number';
296
+ }
297
+
298
+ function isObject(arg) {
299
+ return typeof arg === 'object' && arg !== null;
300
+ }
301
+
302
+ function isUndefined(arg) {
303
+ return arg === void 0;
304
+ }
305
+
306
+ },{}]},{},[1])
307
+ (1)
308
+ });
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: node-events-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Mario Peixoto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ description: Node Event module for Rails asset pipeline
56
+ email:
57
+ - mario.peixoto@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - README.md
63
+ - lib/node/events/rails.rb
64
+ - lib/node/events/rails/engine.rb
65
+ - lib/node/events/rails/version.rb
66
+ - vendor/assets/javascripts/node_events.js
67
+ homepage: https://github.com/mariopeixoto/node-events-rails
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.4.5
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: A gem for distribution of Node Event module for rails
91
+ test_files: []