stampitjs-rails 1.1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c622cb6e006cac6d84a18b604ac0a7fce2c3b9bc
4
+ data.tar.gz: fdd8d761627bebeb64860c736db970b00ff7ea9b
5
+ SHA512:
6
+ metadata.gz: b15d443b63f22121096ddba7be3e8e72f51299622d80dda673e27e248b17596142db22cb643696f2f0caaaf7ed2f25b10466308c20fb9a8c0b4024c391ba2304
7
+ data.tar.gz: 63bd0c292aa36c4009eed575eb1b3935ff780c5af69d00a4e41f6965f53e10898d3f1f984f439bdb578ffd7dfc8ca128e2bc363ef5432c3c4391d8bee3f3940a
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stampitjs-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 brettimus
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Stampitjs::Rails
2
+
3
+ asset gem for [stampit.js](https://github.com/ericelliott/stampit)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'stampitjs-rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install stampitjs-rails
20
+
21
+ ## Usage
22
+
23
+ See the original documentation for [stampit.js](https://github.com/ericelliott/stampit).
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/brettimus/stampitjs-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
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,5 @@
1
+ module Stampitjs
2
+ module Rails
3
+ VERSION = "1.1.0.3"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "stampitjs-rails/version"
2
+
3
+ module Stampitjs
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'stampitjs-rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "stampitjs-rails"
8
+ spec.version = Stampitjs::Rails::VERSION
9
+ spec.authors = ["brettimus"]
10
+ spec.email = ["brbeut@gmail.com"]
11
+ spec.summary = %q{asset gem for javascript library 'stampit'}
12
+ spec.description = %q{adds stampit.js to the asset pipeline to give your app some prototypal syntatic sugah}
13
+ spec.homepage = "https://github.com/brettimus/stampitjs-rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.7"
20
+ spec.add_development_dependency "rake", "~> 10.0"
21
+
22
+ spec.add_dependency "railties", ">= 3.1"
23
+ end
@@ -0,0 +1,747 @@
1
+ !function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.stampit=e():"undefined"!=typeof global?global.stampit=e():"undefined"!=typeof self&&(self.stampit=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
+ var forIn = require('mout/object/forIn');
3
+
4
+ function copyProp(val, key){
5
+ this[key] = val;
6
+ }
7
+
8
+ module.exports = function mixInChain(target, objects){
9
+ var i = 0,
10
+ n = arguments.length,
11
+ obj;
12
+ while(++i < n){
13
+ obj = arguments[i];
14
+ if (obj != null) {
15
+ forIn(obj, copyProp, target);
16
+ }
17
+ }
18
+ return target;
19
+ };
20
+
21
+ },{"mout/object/forIn":14}],2:[function(require,module,exports){
22
+
23
+
24
+ /**
25
+ * Array forEach
26
+ */
27
+ function forEach(arr, callback, thisObj) {
28
+ if (arr == null) {
29
+ return;
30
+ }
31
+ var i = -1,
32
+ len = arr.length;
33
+ while (++i < len) {
34
+ // we iterate over sparse items since there is no way to make it
35
+ // work properly on IE 7-8. see #64
36
+ if ( callback.call(thisObj, arr[i], i, arr) === false ) {
37
+ break;
38
+ }
39
+ }
40
+ }
41
+
42
+ module.exports = forEach;
43
+
44
+
45
+
46
+ },{}],3:[function(require,module,exports){
47
+ var forEach = require('./forEach');
48
+ var makeIterator = require('../function/makeIterator_');
49
+
50
+ /**
51
+ * Array map
52
+ */
53
+ function map(arr, callback, thisObj) {
54
+ callback = makeIterator(callback, thisObj);
55
+ var results = [];
56
+ if (arr == null){
57
+ return results;
58
+ }
59
+
60
+ var i = -1, len = arr.length;
61
+ while (++i < len) {
62
+ results[i] = callback(arr[i], i, arr);
63
+ }
64
+
65
+ return results;
66
+ }
67
+
68
+ module.exports = map;
69
+
70
+
71
+ },{"../function/makeIterator_":4,"./forEach":2}],4:[function(require,module,exports){
72
+ var prop = require('./prop');
73
+ var deepMatches = require('../object/deepMatches');
74
+
75
+ /**
76
+ * Converts argument into a valid iterator.
77
+ * Used internally on most array/object/collection methods that receives a
78
+ * callback/iterator providing a shortcut syntax.
79
+ */
80
+ function makeIterator(src, thisObj){
81
+ switch(typeof src) {
82
+ case 'object':
83
+ // typeof null == "object"
84
+ return (src != null)? function(val, key, target){
85
+ return deepMatches(val, src);
86
+ } : src;
87
+ case 'string':
88
+ case 'number':
89
+ return prop(src);
90
+ case 'function':
91
+ if (typeof thisObj === 'undefined') {
92
+ return src;
93
+ } else {
94
+ return function(val, i, arr){
95
+ return src.call(thisObj, val, i, arr);
96
+ };
97
+ }
98
+ default:
99
+ return src;
100
+ }
101
+ }
102
+
103
+ module.exports = makeIterator;
104
+
105
+
106
+
107
+ },{"../object/deepMatches":13,"./prop":5}],5:[function(require,module,exports){
108
+
109
+
110
+ /**
111
+ * Returns a function that gets a property of the passed object
112
+ */
113
+ function prop(name){
114
+ return function(obj){
115
+ return obj[name];
116
+ };
117
+ }
118
+
119
+ module.exports = prop;
120
+
121
+
122
+
123
+ },{}],6:[function(require,module,exports){
124
+ var kindOf = require('./kindOf');
125
+ var isPlainObject = require('./isPlainObject');
126
+ var mixIn = require('../object/mixIn');
127
+
128
+ /**
129
+ * Clone native types.
130
+ */
131
+ function clone(val){
132
+ switch (kindOf(val)) {
133
+ case 'Object':
134
+ return cloneObject(val);
135
+ case 'Array':
136
+ return cloneArray(val);
137
+ case 'RegExp':
138
+ return cloneRegExp(val);
139
+ case 'Date':
140
+ return cloneDate(val);
141
+ default:
142
+ return val;
143
+ }
144
+ }
145
+
146
+ function cloneObject(source) {
147
+ if (isPlainObject(source)) {
148
+ return mixIn({}, source);
149
+ } else {
150
+ return source;
151
+ }
152
+ }
153
+
154
+ function cloneRegExp(r) {
155
+ var flags = '';
156
+ flags += r.multiline ? 'm' : '';
157
+ flags += r.global ? 'g' : '';
158
+ flags += r.ignorecase ? 'i' : '';
159
+ return new RegExp(r.source, flags);
160
+ }
161
+
162
+ function cloneDate(date) {
163
+ return new Date(+date);
164
+ }
165
+
166
+ function cloneArray(arr) {
167
+ return arr.slice();
168
+ }
169
+
170
+ module.exports = clone;
171
+
172
+
173
+
174
+ },{"../object/mixIn":18,"./isPlainObject":11,"./kindOf":12}],7:[function(require,module,exports){
175
+ var clone = require('./clone');
176
+ var forOwn = require('../object/forOwn');
177
+ var kindOf = require('./kindOf');
178
+ var isPlainObject = require('./isPlainObject');
179
+
180
+ /**
181
+ * Recursively clone native types.
182
+ */
183
+ function deepClone(val, instanceClone) {
184
+ switch ( kindOf(val) ) {
185
+ case 'Object':
186
+ return cloneObject(val, instanceClone);
187
+ case 'Array':
188
+ return cloneArray(val, instanceClone);
189
+ default:
190
+ return clone(val);
191
+ }
192
+ }
193
+
194
+ function cloneObject(source, instanceClone) {
195
+ if (isPlainObject(source)) {
196
+ var out = {};
197
+ forOwn(source, function(val, key) {
198
+ this[key] = deepClone(val, instanceClone);
199
+ }, out);
200
+ return out;
201
+ } else if (instanceClone) {
202
+ return instanceClone(source);
203
+ } else {
204
+ return source;
205
+ }
206
+ }
207
+
208
+ function cloneArray(arr, instanceClone) {
209
+ var out = [],
210
+ i = -1,
211
+ n = arr.length,
212
+ val;
213
+ while (++i < n) {
214
+ out[i] = deepClone(arr[i], instanceClone);
215
+ }
216
+ return out;
217
+ }
218
+
219
+ module.exports = deepClone;
220
+
221
+
222
+
223
+
224
+ },{"../object/forOwn":15,"./clone":6,"./isPlainObject":11,"./kindOf":12}],8:[function(require,module,exports){
225
+ var isKind = require('./isKind');
226
+ /**
227
+ */
228
+ var isArray = Array.isArray || function (val) {
229
+ return isKind(val, 'Array');
230
+ };
231
+ module.exports = isArray;
232
+
233
+
234
+ },{"./isKind":9}],9:[function(require,module,exports){
235
+ var kindOf = require('./kindOf');
236
+ /**
237
+ * Check if value is from a specific "kind".
238
+ */
239
+ function isKind(val, kind){
240
+ return kindOf(val) === kind;
241
+ }
242
+ module.exports = isKind;
243
+
244
+
245
+ },{"./kindOf":12}],10:[function(require,module,exports){
246
+ var isKind = require('./isKind');
247
+ /**
248
+ */
249
+ function isObject(val) {
250
+ return isKind(val, 'Object');
251
+ }
252
+ module.exports = isObject;
253
+
254
+
255
+ },{"./isKind":9}],11:[function(require,module,exports){
256
+
257
+
258
+ /**
259
+ * Checks if the value is created by the `Object` constructor.
260
+ */
261
+ function isPlainObject(value) {
262
+ return (!!value
263
+ && typeof value === 'object'
264
+ && value.constructor === Object);
265
+ }
266
+
267
+ module.exports = isPlainObject;
268
+
269
+
270
+
271
+ },{}],12:[function(require,module,exports){
272
+
273
+
274
+ var _rKind = /^\[object (.*)\]$/,
275
+ _toString = Object.prototype.toString,
276
+ UNDEF;
277
+
278
+ /**
279
+ * Gets the "kind" of value. (e.g. "String", "Number", etc)
280
+ */
281
+ function kindOf(val) {
282
+ if (val === null) {
283
+ return 'Null';
284
+ } else if (val === UNDEF) {
285
+ return 'Undefined';
286
+ } else {
287
+ return _rKind.exec( _toString.call(val) )[1];
288
+ }
289
+ }
290
+ module.exports = kindOf;
291
+
292
+
293
+ },{}],13:[function(require,module,exports){
294
+ var forOwn = require('./forOwn');
295
+ var isArray = require('../lang/isArray');
296
+
297
+ function containsMatch(array, pattern) {
298
+ var i = -1, length = array.length;
299
+ while (++i < length) {
300
+ if (deepMatches(array[i], pattern)) {
301
+ return true;
302
+ }
303
+ }
304
+
305
+ return false;
306
+ }
307
+
308
+ function matchArray(target, pattern) {
309
+ var i = -1, patternLength = pattern.length;
310
+ while (++i < patternLength) {
311
+ if (!containsMatch(target, pattern[i])) {
312
+ return false;
313
+ }
314
+ }
315
+
316
+ return true;
317
+ }
318
+
319
+ function matchObject(target, pattern) {
320
+ var result = true;
321
+ forOwn(pattern, function(val, key) {
322
+ if (!deepMatches(target[key], val)) {
323
+ // Return false to break out of forOwn early
324
+ return (result = false);
325
+ }
326
+ });
327
+
328
+ return result;
329
+ }
330
+
331
+ /**
332
+ * Recursively check if the objects match.
333
+ */
334
+ function deepMatches(target, pattern){
335
+ if (target && typeof target === 'object') {
336
+ if (isArray(target) && isArray(pattern)) {
337
+ return matchArray(target, pattern);
338
+ } else {
339
+ return matchObject(target, pattern);
340
+ }
341
+ } else {
342
+ return target === pattern;
343
+ }
344
+ }
345
+
346
+ module.exports = deepMatches;
347
+
348
+
349
+
350
+ },{"../lang/isArray":8,"./forOwn":15}],14:[function(require,module,exports){
351
+
352
+
353
+ var _hasDontEnumBug,
354
+ _dontEnums;
355
+
356
+ function checkDontEnum(){
357
+ _dontEnums = [
358
+ 'toString',
359
+ 'toLocaleString',
360
+ 'valueOf',
361
+ 'hasOwnProperty',
362
+ 'isPrototypeOf',
363
+ 'propertyIsEnumerable',
364
+ 'constructor'
365
+ ];
366
+
367
+ _hasDontEnumBug = true;
368
+
369
+ for (var key in {'toString': null}) {
370
+ _hasDontEnumBug = false;
371
+ }
372
+ }
373
+
374
+ /**
375
+ * Similar to Array/forEach but works over object properties and fixes Don't
376
+ * Enum bug on IE.
377
+ * based on: http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
378
+ */
379
+ function forIn(obj, fn, thisObj){
380
+ var key, i = 0;
381
+ // no need to check if argument is a real object that way we can use
382
+ // it for arrays, functions, date, etc.
383
+
384
+ //post-pone check till needed
385
+ if (_hasDontEnumBug == null) checkDontEnum();
386
+
387
+ for (key in obj) {
388
+ if (exec(fn, obj, key, thisObj) === false) {
389
+ break;
390
+ }
391
+ }
392
+
393
+ if (_hasDontEnumBug) {
394
+ while (key = _dontEnums[i++]) {
395
+ // since we aren't using hasOwn check we need to make sure the
396
+ // property was overwritten
397
+ if (obj[key] !== Object.prototype[key]) {
398
+ if (exec(fn, obj, key, thisObj) === false) {
399
+ break;
400
+ }
401
+ }
402
+ }
403
+ }
404
+ }
405
+
406
+ function exec(fn, obj, key, thisObj){
407
+ return fn.call(thisObj, obj[key], key, obj);
408
+ }
409
+
410
+ module.exports = forIn;
411
+
412
+
413
+
414
+ },{}],15:[function(require,module,exports){
415
+ var hasOwn = require('./hasOwn');
416
+ var forIn = require('./forIn');
417
+
418
+ /**
419
+ * Similar to Array/forEach but works over object properties and fixes Don't
420
+ * Enum bug on IE.
421
+ * based on: http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
422
+ */
423
+ function forOwn(obj, fn, thisObj){
424
+ forIn(obj, function(val, key){
425
+ if (hasOwn(obj, key)) {
426
+ return fn.call(thisObj, obj[key], key, obj);
427
+ }
428
+ });
429
+ }
430
+
431
+ module.exports = forOwn;
432
+
433
+
434
+
435
+ },{"./forIn":14,"./hasOwn":16}],16:[function(require,module,exports){
436
+
437
+
438
+ /**
439
+ * Safer Object.hasOwnProperty
440
+ */
441
+ function hasOwn(obj, prop){
442
+ return Object.prototype.hasOwnProperty.call(obj, prop);
443
+ }
444
+
445
+ module.exports = hasOwn;
446
+
447
+
448
+
449
+ },{}],17:[function(require,module,exports){
450
+ var hasOwn = require('./hasOwn');
451
+ var deepClone = require('../lang/deepClone');
452
+ var isObject = require('../lang/isObject');
453
+
454
+ /**
455
+ * Deep merge objects.
456
+ */
457
+ function merge() {
458
+ var i = 1,
459
+ key, val, obj, target;
460
+
461
+ // make sure we don't modify source element and it's properties
462
+ // objects are passed by reference
463
+ target = deepClone( arguments[0] );
464
+
465
+ while (obj = arguments[i++]) {
466
+ for (key in obj) {
467
+ if ( ! hasOwn(obj, key) ) {
468
+ continue;
469
+ }
470
+
471
+ val = obj[key];
472
+
473
+ if ( isObject(val) && isObject(target[key]) ){
474
+ // inception, deep merge objects
475
+ target[key] = merge(target[key], val);
476
+ } else {
477
+ // make sure arrays, regexp, date, objects are cloned
478
+ target[key] = deepClone(val);
479
+ }
480
+
481
+ }
482
+ }
483
+
484
+ return target;
485
+ }
486
+
487
+ module.exports = merge;
488
+
489
+
490
+
491
+ },{"../lang/deepClone":7,"../lang/isObject":10,"./hasOwn":16}],18:[function(require,module,exports){
492
+ var forOwn = require('./forOwn');
493
+
494
+ /**
495
+ * Combine properties from all the objects into first one.
496
+ * - This method affects target object in place, if you want to create a new Object pass an empty object as first param.
497
+ * @param {object} target Target Object
498
+ * @param {...object} objects Objects to be combined (0...n objects).
499
+ * @return {object} Target Object.
500
+ */
501
+ function mixIn(target, objects){
502
+ var i = 0,
503
+ n = arguments.length,
504
+ obj;
505
+ while(++i < n){
506
+ obj = arguments[i];
507
+ if (obj != null) {
508
+ forOwn(obj, copyProp, target);
509
+ }
510
+ }
511
+ return target;
512
+ }
513
+
514
+ function copyProp(val, key){
515
+ this[key] = val;
516
+ }
517
+
518
+ module.exports = mixIn;
519
+
520
+
521
+ },{"./forOwn":15}],19:[function(require,module,exports){
522
+ /**
523
+ * Stampit
524
+ **
525
+ * Create objects from reusable, composable behaviors.
526
+ **
527
+ * Copyright (c) 2013 Eric Elliott
528
+ * http://opensource.org/licenses/MIT
529
+ **/
530
+ 'use strict';
531
+ var forEach = require('mout/array/forEach');
532
+ var mixIn = require('mout/object/mixIn');
533
+ var merge = require('mout/object/merge');
534
+ var map = require('mout/array/map');
535
+ var forOwn = require('mout/object/forOwn');
536
+ var mixInChain = require('./mixinchain.js');
537
+ var slice = [].slice;
538
+
539
+ // Avoiding JSHist W003 violations.
540
+ var create, extractFunctions, stampit, compose, isStamp, convertConstructor;
541
+
542
+ create = function (o) {
543
+ if (arguments.length > 1) {
544
+ throw new Error('Object.create implementation only accepts the first parameter.');
545
+ }
546
+ function F() {}
547
+
548
+ F.prototype = o;
549
+ return new F();
550
+ };
551
+
552
+ if (!Array.isArray) {
553
+ Array.isArray = function (vArg) {
554
+ return Object.prototype.toString.call(vArg) === "[object Array]";
555
+ };
556
+ }
557
+
558
+ extractFunctions = function extractFunctions(arg) {
559
+ if (typeof arg === 'function') {
560
+ return map(slice.call(arguments), function (fn) {
561
+ if (typeof fn === 'function') {
562
+ return fn;
563
+ }
564
+ });
565
+ } else if (typeof arg === 'object') {
566
+ var arr = [];
567
+ forEach(slice.call(arguments), function (obj) {
568
+ forOwn(obj, function (fn) {
569
+ arr.push(fn);
570
+ });
571
+ });
572
+ return arr;
573
+ } else if (Array.isArray(arg)) {
574
+ return slice.call(arg);
575
+ }
576
+ return [];
577
+ };
578
+
579
+ /**
580
+ * Return a factory function that will produce new objects using the
581
+ * prototypes that are passed in or composed.
582
+ *
583
+ * @param {Object} [methods] A map of method names and bodies for delegation.
584
+ * @param {Object} [state] A map of property names and values to clone for each new object.
585
+ * @param {Function} [enclose] A closure (function) used to create private data and privileged methods.
586
+ * @return {Function} factory A factory to produce objects using the given prototypes.
587
+ * @return {Function} factory.create Just like calling the factory function.
588
+ * @return {Object} factory.fixed An object map containing the fixed prototypes.
589
+ * @return {Function} factory.methods Add methods to the methods prototype. Chainable.
590
+ * @return {Function} factory.state Add properties to the state prototype. Chainable.
591
+ * @return {Function} factory.enclose Add or replace the closure prototype. Not chainable.
592
+ */
593
+ stampit = function stampit(methods, state, enclose) {
594
+ var fixed = {
595
+ methods: methods || {},
596
+ state: state,
597
+ enclose: extractFunctions(enclose)
598
+ },
599
+
600
+ factory = function factory(properties) {
601
+ var state = merge({}, fixed.state),
602
+ instance = mixIn(create(fixed.methods || {}),
603
+ state, properties),
604
+ closures = fixed.enclose,
605
+ args = slice.call(arguments, 1);
606
+
607
+ forEach(closures, function (fn) {
608
+ if (typeof fn === 'function') {
609
+ instance = fn.apply(instance, args) || instance;
610
+ }
611
+ });
612
+
613
+ return instance;
614
+ };
615
+
616
+ return mixIn(factory, {
617
+ create: factory,
618
+ fixed: fixed,
619
+ /**
620
+ * Take n objects and add them to the methods prototype.
621
+ * @return {Object} stamp The factory in question (`this`).
622
+ */
623
+ methods: function stampMethods() {
624
+ var obj = fixed.methods || {},
625
+ args = [obj].concat(slice.call(arguments));
626
+ fixed.methods = mixInChain.apply(this, args);
627
+ return this;
628
+ },
629
+ /**
630
+ * Take n objects and add them to the state prototype.
631
+ * @return {Object} stamp The factory in question (`this`).
632
+ */
633
+ state: function stampState() {
634
+ var obj = fixed.state || {},
635
+ args = [obj].concat(slice.call(arguments));
636
+ fixed.state = mixIn.apply(this, args);
637
+ return this;
638
+ },
639
+ /**
640
+ * Take n functions, an array of functions, or n objects and add
641
+ * the functions to the enclose prototype.
642
+ * @return {Object} The factory in question (`this`).
643
+ */
644
+ enclose: function stampEnclose() {
645
+ fixed.enclose = fixed.enclose
646
+ .concat(extractFunctions.apply(null, arguments));
647
+ return this;
648
+ },
649
+ /**
650
+ * Take one or more factories produced from stampit() and
651
+ * combine them with `this` to produce and return a new factory.
652
+ * Combining overrides properties with last-in priority.
653
+ * @param {[Function]|...Function} factories Stampit factories.
654
+ * @return {Function} A new stampit factory composed from arguments.
655
+ */
656
+ compose: function (factories) {
657
+ var args = Array.isArray(factories) ? factories : slice.call(arguments);
658
+ args = [this].concat(args);
659
+ return compose(args);
660
+ }
661
+ });
662
+ };
663
+
664
+ /**
665
+ * Take two or more factories produced from stampit() and
666
+ * combine them to produce a new factory.
667
+ * Combining overrides properties with last-in priority.
668
+ * @param {[Function]|...Function} factories A factory produced by stampit().
669
+ * @return {Function} A new stampit factory composed from arguments.
670
+ */
671
+ compose = function compose(factories) {
672
+ factories = Array.isArray(factories) ? factories : slice.call(arguments);
673
+ var result = stampit(),
674
+ f = result.fixed;
675
+ forEach(factories, function (source) {
676
+ if (source && source.fixed) {
677
+ if (source.fixed.methods) {
678
+ f.methods = mixInChain(f.methods, source.fixed.methods);
679
+ }
680
+
681
+ if (source.fixed.state) {
682
+ f.state = mixIn(f.state || {}, source.fixed.state);
683
+ }
684
+
685
+ if (source.fixed.enclose) {
686
+ f.enclose = f.enclose.concat(source.fixed.enclose);
687
+ }
688
+ }
689
+ });
690
+ return result;
691
+ };
692
+
693
+ /**
694
+ * Check if an object is a stamp.
695
+ * @param {Object} obj An object to check.
696
+ * @returns {Boolean}
697
+ */
698
+ isStamp = function isStamp(obj) {
699
+ return (
700
+ typeof obj === 'function' &&
701
+ typeof obj.fixed === 'object' &&
702
+ typeof obj.methods === 'function' &&
703
+ typeof obj.state === 'function' &&
704
+ typeof obj.enclose === 'function'
705
+ );
706
+ };
707
+
708
+ /**
709
+ * Take an old-fashioned JS constructor and return a stampit stamp
710
+ * that you can freely compose with other stamps.
711
+ * @param {Function} Constructor
712
+ * @return {Function} A composable stampit factory
713
+ * (aka stamp).
714
+ */
715
+ convertConstructor = function convertConstructor(Constructor) {
716
+ return stampit().methods(Constructor.prototype).enclose(Constructor);
717
+ };
718
+
719
+ module.exports = mixIn(stampit, {
720
+ compose: compose,
721
+ /**
722
+ * Alias for mixIn
723
+ */
724
+ extend: mixIn,
725
+ /**
726
+ * Take a destination object followed by one or more source objects,
727
+ * and copy the source object properties to the destination object,
728
+ * with last in priority overrides.
729
+ * @param {Object} destination An object to copy properties to.
730
+ * @param {...Object} source An object to copy properties from.
731
+ * @returns {Object}
732
+ */
733
+ mixIn: mixIn,
734
+ /**
735
+ * Check if an object is a stamp.
736
+ * @param {Object} obj An object to check.
737
+ * @returns {Boolean}
738
+ */
739
+ isStamp: isStamp,
740
+
741
+ convertConstructor: convertConstructor
742
+ });
743
+
744
+ },{"./mixinchain.js":1,"mout/array/forEach":2,"mout/array/map":3,"mout/object/forOwn":15,"mout/object/merge":17,"mout/object/mixIn":18}]},{},[19])
745
+ (19)
746
+ });
747
+ ;
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stampitjs-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - brettimus
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-14 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: railties
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: adds stampit.js to the asset pipeline to give your app some prototypal
56
+ syntatic sugah
57
+ email:
58
+ - brbeut@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/stampitjs-rails.rb
69
+ - lib/stampitjs-rails/version.rb
70
+ - stampitjs-rails.gemspec
71
+ - vendor/assets/javascripts/stampit.js
72
+ homepage: https://github.com/brettimus/stampitjs-rails
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.4.3
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: asset gem for javascript library 'stampit'
96
+ test_files: []