flux-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6ab1c91d3011d5aa6ea582897fd67382ad5da3b1
4
+ data.tar.gz: 7a8b4b679d50cc9101dad38f199462739556bc71
5
+ SHA512:
6
+ metadata.gz: 18bb9ae4777e9c3fb5bccc975602ac04d1b015e53dcba2bc7d9f609e1db15a9ebe2af005d1479e85c737e95c9aff8c317cf421babc6344478f0bf5a36779d65f
7
+ data.tar.gz: 085bc5307ff97fe855e7255dfb36bdbb322fcee807ce41a2ab6aa439df8fef738788db34bb3dc9793d99f190fd411184ddd1ecf6511945f7151ef48877bb9cca
@@ -0,0 +1,31 @@
1
+ # Flux::Rails
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'flux-rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install flux-rails
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/flux-rails/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "flux/rails/version"
2
+ require "flux/rails/engine"
@@ -0,0 +1,6 @@
1
+ module Flux
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Flux
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,318 @@
1
+ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)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.Flux=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);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){
2
+ /**
3
+ * Copyright (c) 2014, Facebook, Inc.
4
+ * All rights reserved.
5
+ *
6
+ * This source code is licensed under the BSD-style license found in the
7
+ * LICENSE file in the root directory of this source tree. An additional grant
8
+ * of patent rights can be found in the PATENTS file in the same directory.
9
+ */
10
+
11
+ module.exports.Dispatcher = require('./lib/Dispatcher')
12
+
13
+ },{"./lib/Dispatcher":2}],2:[function(require,module,exports){
14
+ /**
15
+ * Copyright (c) 2014, Facebook, Inc.
16
+ * All rights reserved.
17
+ *
18
+ * This source code is licensed under the BSD-style license found in the
19
+ * LICENSE file in the root directory of this source tree. An additional grant
20
+ * of patent rights can be found in the PATENTS file in the same directory.
21
+ *
22
+ * @providesModule Dispatcher
23
+ * @typechecks
24
+ * @preventMunge
25
+ */
26
+
27
+ "use strict";
28
+
29
+ var invariant = require('./invariant');
30
+
31
+ var _lastID = 1;
32
+ var _prefix = 'ID_';
33
+
34
+ /**
35
+ * Dispatcher is used to broadcast payloads to registered callbacks. This is
36
+ * different from generic pub-sub systems in two ways:
37
+ *
38
+ * 1) Callbacks are not subscribed to particular events. Every payload is
39
+ * dispatched to every registered callback.
40
+ * 2) Callbacks can be deferred in whole or part until other callbacks have
41
+ * been executed.
42
+ *
43
+ * For example, consider this hypothetical flight destination form, which
44
+ * selects a default city when a country is selected:
45
+ *
46
+ * var flightDispatcher = new Dispatcher();
47
+ *
48
+ * // Keeps track of which country is selected
49
+ * var CountryStore = {country: null};
50
+ *
51
+ * // Keeps track of which city is selected
52
+ * var CityStore = {city: null};
53
+ *
54
+ * // Keeps track of the base flight price of the selected city
55
+ * var FlightPriceStore = {price: null}
56
+ *
57
+ * When a user changes the selected city, we dispatch the payload:
58
+ *
59
+ * flightDispatcher.dispatch({
60
+ * actionType: 'city-update',
61
+ * selectedCity: 'paris'
62
+ * });
63
+ *
64
+ * This payload is digested by `CityStore`:
65
+ *
66
+ * flightDispatcher.register(function(payload) {
67
+ * if (payload.actionType === 'city-update') {
68
+ * CityStore.city = payload.selectedCity;
69
+ * }
70
+ * });
71
+ *
72
+ * When the user selects a country, we dispatch the payload:
73
+ *
74
+ * flightDispatcher.dispatch({
75
+ * actionType: 'country-update',
76
+ * selectedCountry: 'australia'
77
+ * });
78
+ *
79
+ * This payload is digested by both stores:
80
+ *
81
+ * CountryStore.dispatchToken = flightDispatcher.register(function(payload) {
82
+ * if (payload.actionType === 'country-update') {
83
+ * CountryStore.country = payload.selectedCountry;
84
+ * }
85
+ * });
86
+ *
87
+ * When the callback to update `CountryStore` is registered, we save a reference
88
+ * to the returned token. Using this token with `waitFor()`, we can guarantee
89
+ * that `CountryStore` is updated before the callback that updates `CityStore`
90
+ * needs to query its data.
91
+ *
92
+ * CityStore.dispatchToken = flightDispatcher.register(function(payload) {
93
+ * if (payload.actionType === 'country-update') {
94
+ * // `CountryStore.country` may not be updated.
95
+ * flightDispatcher.waitFor([CountryStore.dispatchToken]);
96
+ * // `CountryStore.country` is now guaranteed to be updated.
97
+ *
98
+ * // Select the default city for the new country
99
+ * CityStore.city = getDefaultCityForCountry(CountryStore.country);
100
+ * }
101
+ * });
102
+ *
103
+ * The usage of `waitFor()` can be chained, for example:
104
+ *
105
+ * FlightPriceStore.dispatchToken =
106
+ * flightDispatcher.register(function(payload) {
107
+ * switch (payload.actionType) {
108
+ * case 'country-update':
109
+ * case 'city-update':
110
+ * flightDispatcher.waitFor([CityStore.dispatchToken]);
111
+ * FlightPriceStore.price =
112
+ * getFlightPriceStore(CountryStore.country, CityStore.city);
113
+ * break;
114
+ * }
115
+ * });
116
+ *
117
+ * The `country-update` payload will be guaranteed to invoke the stores'
118
+ * registered callbacks in order: `CountryStore`, `CityStore`, then
119
+ * `FlightPriceStore`.
120
+ */
121
+
122
+ function Dispatcher() {
123
+ this._callbacks = {};
124
+ this._isPending = {};
125
+ this._isHandled = {};
126
+ this._isDispatching = false;
127
+ this._pendingPayload = null;
128
+ }
129
+
130
+ /**
131
+ * Registers a callback to be invoked with every dispatched payload. Returns
132
+ * a token that can be used with `waitFor()`.
133
+ *
134
+ * @param {function} callback
135
+ * @return {string}
136
+ */
137
+ Dispatcher.prototype.register=function(callback) {
138
+ var id = _prefix + _lastID++;
139
+ this._callbacks[id] = callback;
140
+ return id;
141
+ };
142
+
143
+ /**
144
+ * Removes a callback based on its token.
145
+ *
146
+ * @param {string} id
147
+ */
148
+ Dispatcher.prototype.unregister=function(id) {
149
+ invariant(
150
+ this._callbacks[id],
151
+ 'Dispatcher.unregister(...): `%s` does not map to a registered callback.',
152
+ id
153
+ );
154
+ delete this._callbacks[id];
155
+ };
156
+
157
+ /**
158
+ * Waits for the callbacks specified to be invoked before continuing execution
159
+ * of the current callback. This method should only be used by a callback in
160
+ * response to a dispatched payload.
161
+ *
162
+ * @param {array<string>} ids
163
+ */
164
+ Dispatcher.prototype.waitFor=function(ids) {
165
+ invariant(
166
+ this._isDispatching,
167
+ 'Dispatcher.waitFor(...): Must be invoked while dispatching.'
168
+ );
169
+ for (var ii = 0; ii < ids.length; ii++) {
170
+ var id = ids[ii];
171
+ if (this._isPending[id]) {
172
+ invariant(
173
+ this._isHandled[id],
174
+ 'Dispatcher.waitFor(...): Circular dependency detected while ' +
175
+ 'waiting for `%s`.',
176
+ id
177
+ );
178
+ continue;
179
+ }
180
+ invariant(
181
+ this._callbacks[id],
182
+ 'Dispatcher.waitFor(...): `%s` does not map to a registered callback.',
183
+ id
184
+ );
185
+ this._invokeCallback(id);
186
+ }
187
+ };
188
+
189
+ /**
190
+ * Dispatches a payload to all registered callbacks.
191
+ *
192
+ * @param {object} payload
193
+ */
194
+ Dispatcher.prototype.dispatch=function(payload) {
195
+ invariant(
196
+ !this._isDispatching,
197
+ 'Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.'
198
+ );
199
+ this._startDispatching(payload);
200
+ try {
201
+ for (var id in this._callbacks) {
202
+ if (this._isPending[id]) {
203
+ continue;
204
+ }
205
+ this._invokeCallback(id);
206
+ }
207
+ } finally {
208
+ this._stopDispatching();
209
+ }
210
+ };
211
+
212
+ /**
213
+ * Is this Dispatcher currently dispatching.
214
+ *
215
+ * @return {boolean}
216
+ */
217
+ Dispatcher.prototype.isDispatching=function() {
218
+ return this._isDispatching;
219
+ };
220
+
221
+ /**
222
+ * Call the callback stored with the given id. Also do some internal
223
+ * bookkeeping.
224
+ *
225
+ * @param {string} id
226
+ * @internal
227
+ */
228
+ Dispatcher.prototype._invokeCallback=function(id) {
229
+ this._isPending[id] = true;
230
+ this._callbacks[id](this._pendingPayload);
231
+ this._isHandled[id] = true;
232
+ };
233
+
234
+ /**
235
+ * Set up bookkeeping needed when dispatching.
236
+ *
237
+ * @param {object} payload
238
+ * @internal
239
+ */
240
+ Dispatcher.prototype._startDispatching=function(payload) {
241
+ for (var id in this._callbacks) {
242
+ this._isPending[id] = false;
243
+ this._isHandled[id] = false;
244
+ }
245
+ this._pendingPayload = payload;
246
+ this._isDispatching = true;
247
+ };
248
+
249
+ /**
250
+ * Clear bookkeeping used for dispatching.
251
+ *
252
+ * @internal
253
+ */
254
+ Dispatcher.prototype._stopDispatching=function() {
255
+ this._pendingPayload = null;
256
+ this._isDispatching = false;
257
+ };
258
+
259
+
260
+ module.exports = Dispatcher;
261
+
262
+ },{"./invariant":3}],3:[function(require,module,exports){
263
+ /**
264
+ * Copyright (c) 2014, Facebook, Inc.
265
+ * All rights reserved.
266
+ *
267
+ * This source code is licensed under the BSD-style license found in the
268
+ * LICENSE file in the root directory of this source tree. An additional grant
269
+ * of patent rights can be found in the PATENTS file in the same directory.
270
+ *
271
+ * @providesModule invariant
272
+ */
273
+
274
+ "use strict";
275
+
276
+ /**
277
+ * Use invariant() to assert state which your program assumes to be true.
278
+ *
279
+ * Provide sprintf-style format (only %s is supported) and arguments
280
+ * to provide information about what broke and what you were
281
+ * expecting.
282
+ *
283
+ * The invariant message will be stripped in production, but the invariant
284
+ * will remain to ensure logic does not differ in production.
285
+ */
286
+
287
+ var invariant = function(condition, format, a, b, c, d, e, f) {
288
+ if (false) {
289
+ if (format === undefined) {
290
+ throw new Error('invariant requires an error message argument');
291
+ }
292
+ }
293
+
294
+ if (!condition) {
295
+ var error;
296
+ if (format === undefined) {
297
+ error = new Error(
298
+ 'Minified exception occurred; use the non-minified dev environment ' +
299
+ 'for the full error message and additional helpful warnings.'
300
+ );
301
+ } else {
302
+ var args = [a, b, c, d, e, f];
303
+ var argIndex = 0;
304
+ error = new Error(
305
+ 'Invariant Violation: ' +
306
+ format.replace(/%s/g, function() { return args[argIndex++]; })
307
+ );
308
+ }
309
+
310
+ error.framesToPop = 1; // we don't care about invariant's own frame
311
+ throw error;
312
+ }
313
+ };
314
+
315
+ module.exports = invariant;
316
+
317
+ },{}]},{},[1])(1)
318
+ });
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flux-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
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: Flux 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/flux/rails.rb
64
+ - lib/flux/rails/engine.rb
65
+ - lib/flux/rails/version.rb
66
+ - vendor/assets/javascript/flux.js
67
+ homepage: https://github.com/mariopeixoto/flux-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 the facebook's flux library
91
+ test_files: []