ende 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/component.json +4 -2
  3. data/ende.gemspec +1 -0
  4. data/lib/assets/javascripts/aura/extensions/devise.js.coffee +94 -15
  5. data/lib/assets/javascripts/aura/extensions/routes.js.coffee +21 -0
  6. data/lib/assets/javascripts/aura/extensions/states.js.coffee +3 -1
  7. data/lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee +19 -21
  8. data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +17 -1
  9. data/lib/assets/javascripts/config/initializers/jquery.js.coffee +4 -3
  10. data/lib/assets/javascripts/config/initializers/load_components.js.coffee +19 -0
  11. data/lib/assets/javascripts/ende.js.coffee +3 -1
  12. data/lib/assets/javascripts/widgets/authenticator/main.js.coffee +3 -3
  13. data/lib/assets/javascripts/widgets/viewer/main.js.coffee +189 -120
  14. data/lib/ende/users_controller_extensions.rb +14 -0
  15. data/lib/ende/version.rb +1 -1
  16. data/lib/ende.rb +5 -0
  17. data/vendor/assets/components/KapIT-observe-utils/component.json +16 -0
  18. data/vendor/assets/components/KapIT-observe-utils/lib/observe-utils.js +780 -0
  19. data/vendor/assets/components/chaijs-assertion-error/component.json +18 -0
  20. data/vendor/assets/components/chaijs-assertion-error/index.js +110 -0
  21. data/vendor/assets/components/chaijs-chai/component.json +47 -0
  22. data/vendor/assets/components/chaijs-chai/index.js +1 -0
  23. data/vendor/assets/components/chaijs-chai/lib/chai/assertion.js +130 -0
  24. data/vendor/assets/components/chaijs-chai/lib/chai/core/assertions.js +1270 -0
  25. data/vendor/assets/components/chaijs-chai/lib/chai/interface/assert.js +1080 -0
  26. data/vendor/assets/components/chaijs-chai/lib/chai/interface/expect.js +12 -0
  27. data/vendor/assets/components/chaijs-chai/lib/chai/interface/should.js +76 -0
  28. data/vendor/assets/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +94 -0
  29. data/vendor/assets/components/chaijs-chai/lib/chai/utils/addMethod.js +37 -0
  30. data/vendor/assets/components/chaijs-chai/lib/chai/utils/addProperty.js +40 -0
  31. data/vendor/assets/components/chaijs-chai/lib/chai/utils/flag.js +32 -0
  32. data/vendor/assets/components/chaijs-chai/lib/chai/utils/getActual.js +19 -0
  33. data/vendor/assets/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +25 -0
  34. data/vendor/assets/components/chaijs-chai/lib/chai/utils/getMessage.js +49 -0
  35. data/vendor/assets/components/chaijs-chai/lib/chai/utils/getName.js +20 -0
  36. data/vendor/assets/components/chaijs-chai/lib/chai/utils/getPathValue.js +102 -0
  37. data/vendor/assets/components/chaijs-chai/lib/chai/utils/getProperties.js +35 -0
  38. data/vendor/assets/components/chaijs-chai/lib/chai/utils/index.js +108 -0
  39. data/vendor/assets/components/chaijs-chai/lib/chai/utils/inspect.js +320 -0
  40. data/vendor/assets/components/chaijs-chai/lib/chai/utils/objDisplay.js +48 -0
  41. data/vendor/assets/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +51 -0
  42. data/vendor/assets/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +54 -0
  43. data/vendor/assets/components/chaijs-chai/lib/chai/utils/test.js +26 -0
  44. data/vendor/assets/components/chaijs-chai/lib/chai/utils/transferFlags.js +44 -0
  45. data/vendor/assets/components/chaijs-chai/lib/chai/utils/type.js +45 -0
  46. data/vendor/assets/components/chaijs-chai/lib/chai.js +80 -0
  47. data/vendor/assets/components/chaijs-deep-eql/component.json +18 -0
  48. data/vendor/assets/components/chaijs-deep-eql/lib/eql.js +257 -0
  49. data/vendor/assets/components/chaijs-type-detect/component.json +16 -0
  50. data/vendor/assets/components/chaijs-type-detect/lib/type.js +142 -0
  51. data/vendor/assets/components/component-bind/component.json +14 -0
  52. data/vendor/assets/components/component-bind/index.js +24 -0
  53. data/vendor/assets/components/component-delegate/component.json +19 -0
  54. data/vendor/assets/components/component-delegate/index.js +42 -0
  55. data/vendor/assets/components/component-event/component.json +13 -0
  56. data/vendor/assets/components/component-event/index.js +40 -0
  57. data/vendor/assets/components/component-jquery/component.json +14 -0
  58. data/vendor/assets/components/component-jquery/index.js +9601 -0
  59. data/vendor/assets/components/component-link-delegate/component.json +23 -0
  60. data/vendor/assets/components/component-link-delegate/index.js +60 -0
  61. data/vendor/assets/components/component-matches-selector/component.json +20 -0
  62. data/vendor/assets/components/component-matches-selector/index.js +45 -0
  63. data/vendor/assets/components/component-query/component.json +21 -0
  64. data/vendor/assets/components/component-query/index.js +21 -0
  65. data/vendor/assets/components/component-type/component.json +18 -0
  66. data/vendor/assets/components/component-type/index.js +32 -0
  67. data/vendor/assets/components/component-url/component.json +17 -0
  68. data/vendor/assets/components/component-url/index.js +63 -0
  69. data/vendor/assets/components/discore-closest/component.json +14 -0
  70. data/vendor/assets/components/discore-closest/index.js +18 -0
  71. data/vendor/assets/components/indefinido-advisable/component.json +21 -0
  72. data/vendor/assets/components/indefinido-advisable/index.js +1 -0
  73. data/vendor/assets/components/indefinido-advisable/lib/advisable.js +60 -0
  74. data/vendor/assets/components/indefinido-indemma/component.json +40 -0
  75. data/vendor/assets/components/indefinido-indemma/index.js +1 -0
  76. data/vendor/assets/components/indefinido-indemma/lib/extensions/rivets.js +23 -0
  77. data/vendor/assets/components/indefinido-indemma/lib/record/associable.js +217 -0
  78. data/vendor/assets/components/indefinido-indemma/lib/record/maid.js +24 -0
  79. data/vendor/assets/components/indefinido-indemma/lib/record/resource.js +104 -0
  80. data/vendor/assets/components/indefinido-indemma/lib/record/rest.js +36 -0
  81. data/vendor/assets/components/indefinido-indemma/lib/record/restfulable.js +326 -0
  82. data/vendor/assets/components/indefinido-indemma/lib/record/scopable.js +279 -0
  83. data/vendor/assets/components/indefinido-indemma/lib/record/translationable.js +19 -0
  84. data/vendor/assets/components/indefinido-indemma/lib/record/validatable.js +216 -0
  85. data/vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js +30 -0
  86. data/vendor/assets/components/indefinido-indemma/lib/record/validations/confirmation.js +19 -0
  87. data/vendor/assets/components/indefinido-indemma/lib/record/validations/cpf.js +60 -0
  88. data/vendor/assets/components/indefinido-indemma/lib/record/validations/presence.js +19 -0
  89. data/vendor/assets/components/indefinido-indemma/lib/record/validations/remote.js +71 -0
  90. data/vendor/assets/components/indefinido-indemma/lib/record.js +167 -0
  91. data/vendor/assets/components/indefinido-indemma/vendor/sinon.js +4290 -0
  92. data/vendor/assets/components/indefinido-indemma/vendor/stampit.js +392 -0
  93. data/vendor/assets/components/indefinido-observable/component.json +25 -0
  94. data/vendor/assets/components/indefinido-observable/components/cjohansen-sinon/sinon.js +4290 -0
  95. data/vendor/assets/components/indefinido-observable/index.js +1 -0
  96. data/vendor/assets/components/indefinido-observable/lib/adapters/rivets.js +26 -0
  97. data/vendor/assets/components/indefinido-observable/lib/observable.js +320 -0
  98. data/vendor/assets/components/indefinido-observable/vendor/shims/accessors-legacy.js +92 -0
  99. data/vendor/assets/components/indefinido-observable/vendor/shims/accessors.js +173 -0
  100. data/vendor/assets/components/indefinido-observable/vendor/shims/array.indexOf.js +8 -0
  101. data/vendor/assets/components/indefinido-observable/vendor/shims/object.create.js +77 -0
  102. data/vendor/assets/components/mikeric-rivets/component.json +15 -0
  103. data/vendor/assets/components/mikeric-rivets/dist/rivets.js +1020 -0
  104. data/vendor/assets/components/paulmillr-es6-shim/component.json +17 -0
  105. data/vendor/assets/components/paulmillr-es6-shim/es6-shim.js +985 -0
  106. data/vendor/assets/components/pluma-assimilate/component.json +25 -0
  107. data/vendor/assets/components/pluma-assimilate/dist/assimilate.js +87 -0
  108. data/vendor/assets/components/segmentio-extend/component.json +13 -0
  109. data/vendor/assets/components/segmentio-extend/index.js +15 -0
  110. data/vendor/assets/javascripts/ende/build.js +30346 -0
  111. data/vendor/assets/javascripts/jquery/inview.js +125 -0
  112. data/vendor/assets/javascripts/lennon/lennon.js +184 -0
  113. metadata +114 -3
  114. data/lib/tasks/sprite.thor +0 -62
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * chai
3
+ * Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
4
+ * MIT Licensed
5
+ */
6
+
7
+ module.exports = function (chai, util) {
8
+ chai.expect = function (val, message) {
9
+ return new chai.Assertion(val, message);
10
+ };
11
+ };
12
+
@@ -0,0 +1,76 @@
1
+ /*!
2
+ * chai
3
+ * Copyright(c) 2011-2013 Jake Luer <jake@alogicalparadox.com>
4
+ * MIT Licensed
5
+ */
6
+
7
+ module.exports = function (chai, util) {
8
+ var Assertion = chai.Assertion;
9
+
10
+ function loadShould () {
11
+ // modify Object.prototype to have `should`
12
+ Object.defineProperty(Object.prototype, 'should',
13
+ {
14
+ set: function (value) {
15
+ // See https://github.com/chaijs/chai/issues/86: this makes
16
+ // `whatever.should = someValue` actually set `someValue`, which is
17
+ // especially useful for `global.should = require('chai').should()`.
18
+ //
19
+ // Note that we have to use [[DefineProperty]] instead of [[Put]]
20
+ // since otherwise we would trigger this very setter!
21
+ Object.defineProperty(this, 'should', {
22
+ value: value,
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true
26
+ });
27
+ }
28
+ , get: function(){
29
+ if (this instanceof String || this instanceof Number) {
30
+ return new Assertion(this.constructor(this));
31
+ } else if (this instanceof Boolean) {
32
+ return new Assertion(this == true);
33
+ }
34
+ return new Assertion(this);
35
+ }
36
+ , configurable: true
37
+ });
38
+
39
+ var should = {};
40
+
41
+ should.equal = function (val1, val2, msg) {
42
+ new Assertion(val1, msg).to.equal(val2);
43
+ };
44
+
45
+ should.Throw = function (fn, errt, errs, msg) {
46
+ new Assertion(fn, msg).to.Throw(errt, errs);
47
+ };
48
+
49
+ should.exist = function (val, msg) {
50
+ new Assertion(val, msg).to.exist;
51
+ }
52
+
53
+ // negation
54
+ should.not = {}
55
+
56
+ should.not.equal = function (val1, val2, msg) {
57
+ new Assertion(val1, msg).to.not.equal(val2);
58
+ };
59
+
60
+ should.not.Throw = function (fn, errt, errs, msg) {
61
+ new Assertion(fn, msg).to.not.Throw(errt, errs);
62
+ };
63
+
64
+ should.not.exist = function (val, msg) {
65
+ new Assertion(val, msg).to.not.exist;
66
+ }
67
+
68
+ should['throw'] = should['Throw'];
69
+ should.not['throw'] = should.not['Throw'];
70
+
71
+ return should;
72
+ };
73
+
74
+ chai.should = loadShould;
75
+ chai.Should = loadShould;
76
+ };
@@ -0,0 +1,94 @@
1
+ /*!
2
+ * Chai - addChainingMethod utility
3
+ * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
4
+ * MIT Licensed
5
+ */
6
+
7
+ /*!
8
+ * Module dependencies
9
+ */
10
+
11
+ var transferFlags = require('./transferFlags');
12
+
13
+ /*!
14
+ * Module variables
15
+ */
16
+
17
+ // Check whether `__proto__` is supported
18
+ var hasProtoSupport = '__proto__' in Object;
19
+
20
+ // Without `__proto__` support, this module will need to add properties to a function.
21
+ // However, some Function.prototype methods cannot be overwritten,
22
+ // and there seems no easy cross-platform way to detect them (@see chaijs/chai/issues/69).
23
+ var excludeNames = /^(?:length|name|arguments|caller)$/;
24
+
25
+ // Cache `Function` properties
26
+ var call = Function.prototype.call,
27
+ apply = Function.prototype.apply;
28
+
29
+ /**
30
+ * ### addChainableMethod (ctx, name, method, chainingBehavior)
31
+ *
32
+ * Adds a method to an object, such that the method can also be chained.
33
+ *
34
+ * utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) {
35
+ * var obj = utils.flag(this, 'object');
36
+ * new chai.Assertion(obj).to.be.equal(str);
37
+ * });
38
+ *
39
+ * Can also be accessed directly from `chai.Assertion`.
40
+ *
41
+ * chai.Assertion.addChainableMethod('foo', fn, chainingBehavior);
42
+ *
43
+ * The result can then be used as both a method assertion, executing both `method` and
44
+ * `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`.
45
+ *
46
+ * expect(fooStr).to.be.foo('bar');
47
+ * expect(fooStr).to.be.foo.equal('foo');
48
+ *
49
+ * @param {Object} ctx object to which the method is added
50
+ * @param {String} name of method to add
51
+ * @param {Function} method function to be used for `name`, when called
52
+ * @param {Function} chainingBehavior function to be called every time the property is accessed
53
+ * @name addChainableMethod
54
+ * @api public
55
+ */
56
+
57
+ module.exports = function (ctx, name, method, chainingBehavior) {
58
+ if (typeof chainingBehavior !== 'function')
59
+ chainingBehavior = function () { };
60
+
61
+ Object.defineProperty(ctx, name,
62
+ { get: function () {
63
+ chainingBehavior.call(this);
64
+
65
+ var assert = function () {
66
+ var result = method.apply(this, arguments);
67
+ return result === undefined ? this : result;
68
+ };
69
+
70
+ // Use `__proto__` if available
71
+ if (hasProtoSupport) {
72
+ // Inherit all properties from the object by replacing the `Function` prototype
73
+ var prototype = assert.__proto__ = Object.create(this);
74
+ // Restore the `call` and `apply` methods from `Function`
75
+ prototype.call = call;
76
+ prototype.apply = apply;
77
+ }
78
+ // Otherwise, redefine all properties (slow!)
79
+ else {
80
+ var asserterNames = Object.getOwnPropertyNames(ctx);
81
+ asserterNames.forEach(function (asserterName) {
82
+ if (!excludeNames.test(asserterName)) {
83
+ var pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
84
+ Object.defineProperty(assert, asserterName, pd);
85
+ }
86
+ });
87
+ }
88
+
89
+ transferFlags(this, assert);
90
+ return assert;
91
+ }
92
+ , configurable: true
93
+ });
94
+ };
@@ -0,0 +1,37 @@
1
+ /*!
2
+ * Chai - addMethod utility
3
+ * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
4
+ * MIT Licensed
5
+ */
6
+
7
+ /**
8
+ * ### .addMethod (ctx, name, method)
9
+ *
10
+ * Adds a method to the prototype of an object.
11
+ *
12
+ * utils.addMethod(chai.Assertion.prototype, 'foo', function (str) {
13
+ * var obj = utils.flag(this, 'object');
14
+ * new chai.Assertion(obj).to.be.equal(str);
15
+ * });
16
+ *
17
+ * Can also be accessed directly from `chai.Assertion`.
18
+ *
19
+ * chai.Assertion.addMethod('foo', fn);
20
+ *
21
+ * Then can be used as any other assertion.
22
+ *
23
+ * expect(fooStr).to.be.foo('bar');
24
+ *
25
+ * @param {Object} ctx object to which the method is added
26
+ * @param {String} name of method to add
27
+ * @param {Function} method function to be used for name
28
+ * @name addMethod
29
+ * @api public
30
+ */
31
+
32
+ module.exports = function (ctx, name, method) {
33
+ ctx[name] = function () {
34
+ var result = method.apply(this, arguments);
35
+ return result === undefined ? this : result;
36
+ };
37
+ };
@@ -0,0 +1,40 @@
1
+ /*!
2
+ * Chai - addProperty utility
3
+ * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
4
+ * MIT Licensed
5
+ */
6
+
7
+ /**
8
+ * ### addProperty (ctx, name, getter)
9
+ *
10
+ * Adds a property to the prototype of an object.
11
+ *
12
+ * utils.addProperty(chai.Assertion.prototype, 'foo', function () {
13
+ * var obj = utils.flag(this, 'object');
14
+ * new chai.Assertion(obj).to.be.instanceof(Foo);
15
+ * });
16
+ *
17
+ * Can also be accessed directly from `chai.Assertion`.
18
+ *
19
+ * chai.Assertion.addProperty('foo', fn);
20
+ *
21
+ * Then can be used as any other assertion.
22
+ *
23
+ * expect(myFoo).to.be.foo;
24
+ *
25
+ * @param {Object} ctx object to which the property is added
26
+ * @param {String} name of property to add
27
+ * @param {Function} getter function to be used for name
28
+ * @name addProperty
29
+ * @api public
30
+ */
31
+
32
+ module.exports = function (ctx, name, getter) {
33
+ Object.defineProperty(ctx, name,
34
+ { get: function () {
35
+ var result = getter.call(this);
36
+ return result === undefined ? this : result;
37
+ }
38
+ , configurable: true
39
+ });
40
+ };
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * Chai - flag utility
3
+ * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
4
+ * MIT Licensed
5
+ */
6
+
7
+ /**
8
+ * ### flag(object ,key, [value])
9
+ *
10
+ * Get or set a flag value on an object. If a
11
+ * value is provided it will be set, else it will
12
+ * return the currently set value or `undefined` if
13
+ * the value is not set.
14
+ *
15
+ * utils.flag(this, 'foo', 'bar'); // setter
16
+ * utils.flag(this, 'foo'); // getter, returns `bar`
17
+ *
18
+ * @param {Object} object (constructed Assertion
19
+ * @param {String} key
20
+ * @param {Mixed} value (optional)
21
+ * @name flag
22
+ * @api private
23
+ */
24
+
25
+ module.exports = function (obj, key, value) {
26
+ var flags = obj.__flags || (obj.__flags = Object.create(null));
27
+ if (arguments.length === 3) {
28
+ flags[key] = value;
29
+ } else {
30
+ return flags[key];
31
+ }
32
+ };
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * Chai - getActual utility
3
+ * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
4
+ * MIT Licensed
5
+ */
6
+
7
+ /**
8
+ * # getActual(object, [actual])
9
+ *
10
+ * Returns the `actual` value for an Assertion
11
+ *
12
+ * @param {Object} object (constructed Assertion)
13
+ * @param {Arguments} chai.Assertion.prototype.assert arguments
14
+ */
15
+
16
+ module.exports = function (obj, args) {
17
+ var actual = args[4];
18
+ return 'undefined' !== typeof actual ? actual : obj._obj;
19
+ };
@@ -0,0 +1,25 @@
1
+ /*!
2
+ * Chai - getEnumerableProperties utility
3
+ * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
4
+ * MIT Licensed
5
+ */
6
+
7
+ /**
8
+ * ### .getEnumerableProperties(object)
9
+ *
10
+ * This allows the retrieval of enumerable property names of an object,
11
+ * inherited or not.
12
+ *
13
+ * @param {Object} object
14
+ * @returns {Array}
15
+ * @name getEnumerableProperties
16
+ * @api public
17
+ */
18
+
19
+ module.exports = function getEnumerableProperties(object) {
20
+ var result = [];
21
+ for (var name in object) {
22
+ result.push(name);
23
+ }
24
+ return result;
25
+ };
@@ -0,0 +1,49 @@
1
+ /*!
2
+ * Chai - message composition utility
3
+ * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
4
+ * MIT Licensed
5
+ */
6
+
7
+ /*!
8
+ * Module dependancies
9
+ */
10
+
11
+ var flag = require('./flag')
12
+ , getActual = require('./getActual')
13
+ , inspect = require('./inspect')
14
+ , objDisplay = require('./objDisplay');
15
+
16
+ /**
17
+ * ### .getMessage(object, message, negateMessage)
18
+ *
19
+ * Construct the error message based on flags
20
+ * and template tags. Template tags will return
21
+ * a stringified inspection of the object referenced.
22
+ *
23
+ * Message template tags:
24
+ * - `#{this}` current asserted object
25
+ * - `#{act}` actual value
26
+ * - `#{exp}` expected value
27
+ *
28
+ * @param {Object} object (constructed Assertion)
29
+ * @param {Arguments} chai.Assertion.prototype.assert arguments
30
+ * @name getMessage
31
+ * @api public
32
+ */
33
+
34
+ module.exports = function (obj, args) {
35
+ var negate = flag(obj, 'negate')
36
+ , val = flag(obj, 'object')
37
+ , expected = args[3]
38
+ , actual = getActual(obj, args)
39
+ , msg = negate ? args[2] : args[1]
40
+ , flagMsg = flag(obj, 'message');
41
+
42
+ msg = msg || '';
43
+ msg = msg
44
+ .replace(/#{this}/g, objDisplay(val))
45
+ .replace(/#{act}/g, objDisplay(actual))
46
+ .replace(/#{exp}/g, objDisplay(expected));
47
+
48
+ return flagMsg ? flagMsg + ': ' + msg : msg;
49
+ };
@@ -0,0 +1,20 @@
1
+ /*!
2
+ * Chai - getName utility
3
+ * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
4
+ * MIT Licensed
5
+ */
6
+
7
+ /**
8
+ * # getName(func)
9
+ *
10
+ * Gets the name of a function, in a cross-browser way.
11
+ *
12
+ * @param {Function} a function (usually a constructor)
13
+ */
14
+
15
+ module.exports = function (func) {
16
+ if (func.name) return func.name;
17
+
18
+ var match = /^\s?function ([^(]*)\(/.exec(func);
19
+ return match && match[1] ? match[1] : "";
20
+ };
@@ -0,0 +1,102 @@
1
+ /*!
2
+ * Chai - getPathValue utility
3
+ * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
4
+ * @see https://github.com/logicalparadox/filtr
5
+ * MIT Licensed
6
+ */
7
+
8
+ /**
9
+ * ### .getPathValue(path, object)
10
+ *
11
+ * This allows the retrieval of values in an
12
+ * object given a string path.
13
+ *
14
+ * var obj = {
15
+ * prop1: {
16
+ * arr: ['a', 'b', 'c']
17
+ * , str: 'Hello'
18
+ * }
19
+ * , prop2: {
20
+ * arr: [ { nested: 'Universe' } ]
21
+ * , str: 'Hello again!'
22
+ * }
23
+ * }
24
+ *
25
+ * The following would be the results.
26
+ *
27
+ * getPathValue('prop1.str', obj); // Hello
28
+ * getPathValue('prop1.att[2]', obj); // b
29
+ * getPathValue('prop2.arr[0].nested', obj); // Universe
30
+ *
31
+ * @param {String} path
32
+ * @param {Object} object
33
+ * @returns {Object} value or `undefined`
34
+ * @name getPathValue
35
+ * @api public
36
+ */
37
+
38
+ var getPathValue = module.exports = function (path, obj) {
39
+ var parsed = parsePath(path);
40
+ return _getPathValue(parsed, obj);
41
+ };
42
+
43
+ /*!
44
+ * ## parsePath(path)
45
+ *
46
+ * Helper function used to parse string object
47
+ * paths. Use in conjunction with `_getPathValue`.
48
+ *
49
+ * var parsed = parsePath('myobject.property.subprop');
50
+ *
51
+ * ### Paths:
52
+ *
53
+ * * Can be as near infinitely deep and nested
54
+ * * Arrays are also valid using the formal `myobject.document[3].property`.
55
+ *
56
+ * @param {String} path
57
+ * @returns {Object} parsed
58
+ * @api private
59
+ */
60
+
61
+ function parsePath (path) {
62
+ var str = path.replace(/\[/g, '.[')
63
+ , parts = str.match(/(\\\.|[^.]+?)+/g);
64
+ return parts.map(function (value) {
65
+ var re = /\[(\d+)\]$/
66
+ , mArr = re.exec(value)
67
+ if (mArr) return { i: parseFloat(mArr[1]) };
68
+ else return { p: value };
69
+ });
70
+ };
71
+
72
+ /*!
73
+ * ## _getPathValue(parsed, obj)
74
+ *
75
+ * Helper companion function for `.parsePath` that returns
76
+ * the value located at the parsed address.
77
+ *
78
+ * var value = getPathValue(parsed, obj);
79
+ *
80
+ * @param {Object} parsed definition from `parsePath`.
81
+ * @param {Object} object to search against
82
+ * @returns {Object|Undefined} value
83
+ * @api private
84
+ */
85
+
86
+ function _getPathValue (parsed, obj) {
87
+ var tmp = obj
88
+ , res;
89
+ for (var i = 0, l = parsed.length; i < l; i++) {
90
+ var part = parsed[i];
91
+ if (tmp) {
92
+ if ('undefined' !== typeof part.p)
93
+ tmp = tmp[part.p];
94
+ else if ('undefined' !== typeof part.i)
95
+ tmp = tmp[part.i];
96
+ if (i == (l - 1)) res = tmp;
97
+ } else {
98
+ res = undefined;
99
+ }
100
+ }
101
+ return res;
102
+ };
@@ -0,0 +1,35 @@
1
+ /*!
2
+ * Chai - getProperties utility
3
+ * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com>
4
+ * MIT Licensed
5
+ */
6
+
7
+ /**
8
+ * ### .getProperties(object)
9
+ *
10
+ * This allows the retrieval of property names of an object, enumerable or not,
11
+ * inherited or not.
12
+ *
13
+ * @param {Object} object
14
+ * @returns {Array}
15
+ * @name getProperties
16
+ * @api public
17
+ */
18
+
19
+ module.exports = function getProperties(object) {
20
+ var result = Object.getOwnPropertyNames(subject);
21
+
22
+ function addProperty(property) {
23
+ if (result.indexOf(property) === -1) {
24
+ result.push(property);
25
+ }
26
+ }
27
+
28
+ var proto = Object.getPrototypeOf(subject);
29
+ while (proto !== null) {
30
+ Object.getOwnPropertyNames(proto).forEach(addProperty);
31
+ proto = Object.getPrototypeOf(proto);
32
+ }
33
+
34
+ return result;
35
+ };
@@ -0,0 +1,108 @@
1
+ /*!
2
+ * chai
3
+ * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
4
+ * MIT Licensed
5
+ */
6
+
7
+ /*!
8
+ * Main exports
9
+ */
10
+
11
+ var exports = module.exports = {};
12
+
13
+ /*!
14
+ * test utility
15
+ */
16
+
17
+ exports.test = require('./test');
18
+
19
+ /*!
20
+ * type utility
21
+ */
22
+
23
+ exports.type = require('./type');
24
+
25
+ /*!
26
+ * message utility
27
+ */
28
+
29
+ exports.getMessage = require('./getMessage');
30
+
31
+ /*!
32
+ * actual utility
33
+ */
34
+
35
+ exports.getActual = require('./getActual');
36
+
37
+ /*!
38
+ * Inspect util
39
+ */
40
+
41
+ exports.inspect = require('./inspect');
42
+
43
+ /*!
44
+ * Object Display util
45
+ */
46
+
47
+ exports.objDisplay = require('./objDisplay');
48
+
49
+ /*!
50
+ * Flag utility
51
+ */
52
+
53
+ exports.flag = require('./flag');
54
+
55
+ /*!
56
+ * Flag transferring utility
57
+ */
58
+
59
+ exports.transferFlags = require('./transferFlags');
60
+
61
+ /*!
62
+ * Deep equal utility
63
+ */
64
+
65
+ exports.eql = require('deep-eql');
66
+
67
+ /*!
68
+ * Deep path value
69
+ */
70
+
71
+ exports.getPathValue = require('./getPathValue');
72
+
73
+ /*!
74
+ * Function name
75
+ */
76
+
77
+ exports.getName = require('./getName');
78
+
79
+ /*!
80
+ * add Property
81
+ */
82
+
83
+ exports.addProperty = require('./addProperty');
84
+
85
+ /*!
86
+ * add Method
87
+ */
88
+
89
+ exports.addMethod = require('./addMethod');
90
+
91
+ /*!
92
+ * overwrite Property
93
+ */
94
+
95
+ exports.overwriteProperty = require('./overwriteProperty');
96
+
97
+ /*!
98
+ * overwrite Method
99
+ */
100
+
101
+ exports.overwriteMethod = require('./overwriteMethod');
102
+
103
+ /*!
104
+ * Add a chainable method
105
+ */
106
+
107
+ exports.addChainableMethod = require('./addChainableMethod');
108
+