ende 0.4.20 → 0.4.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -3
  3. data/build/build.css +111 -0
  4. data/component.json +1 -0
  5. data/lib/assets/javascripts/aura/extensions/models.js.coffee.erb +4 -13
  6. data/lib/assets/javascripts/aura/extensions/platform.js.coffee +2 -8
  7. data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +21 -10
  8. data/lib/assets/javascripts/aura/extensions/states.js.coffee +25 -27
  9. data/lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee +28 -23
  10. data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +21 -34
  11. data/lib/assets/javascripts/aura/extensions/widget/napable.js.coffee +17 -13
  12. data/lib/assets/javascripts/config/load_components.js.coffee +5 -7
  13. data/lib/assets/javascripts/widgets/dialog/main.js.coffee +1 -2
  14. data/lib/assets/javascripts/widgets/list/presenter.js.coffee +5 -4
  15. data/lib/assets/javascripts/widgets/support/adapters/olark.js +1 -1
  16. data/lib/assets/javascripts/widgets/tray/main.js.coffee +16 -22
  17. data/lib/assets/javascripts/widgets/viewer/main.js.coffee +39 -102
  18. data/lib/assets/javascripts/widgets/viewer/plugins/scopable.js.coffee +7 -1
  19. data/lib/ende/version.rb +1 -1
  20. data/vendor/assets/components/ende_build.js +5732 -1047
  21. data/vendor/components/indefinido-indemma/build/development.js +2 -2
  22. data/vendor/components/indefinido-indemma/build/release.js +9 -4
  23. data/vendor/components/indefinido-indemma/build/test.js +115 -21916
  24. data/vendor/components/indefinido-indemma/component.json +0 -1
  25. data/vendor/components/indefinido-indemma/lib/record/restfulable.js +7 -2
  26. data/vendor/components/indefinido-indemma/lib/record/validatable.js +2 -2
  27. data/vendor/components/indefinido-indemma/src/lib/record/persistable.coffee +2 -0
  28. data/vendor/components/indefinido-indemma/src/lib/record/resource.coffee +3 -2
  29. data/vendor/components/indefinido-indemma/src/lib/record/restfulable.coffee +16 -4
  30. data/vendor/components/indefinido-indemma/src/lib/record/validatable.coffee +3 -3
  31. data/vendor/components/indefinido-observable/.gitignore +15 -0
  32. data/vendor/components/indefinido-observable/.ruby-gemset +1 -0
  33. data/vendor/components/indefinido-observable/.ruby-version +1 -0
  34. data/vendor/components/indefinido-observable/Gemfile +13 -0
  35. data/vendor/components/indefinido-observable/Guardfile +39 -0
  36. data/vendor/components/indefinido-observable/History.md +0 -0
  37. data/vendor/components/indefinido-observable/Readme.md +116 -0
  38. data/vendor/components/indefinido-observable/build/build.js +14798 -0
  39. data/vendor/components/indefinido-observable/build/development.js +339 -0
  40. data/vendor/components/indefinido-observable/build/release.js +14937 -0
  41. data/vendor/components/indefinido-observable/build/test.js +339 -0
  42. data/vendor/components/indefinido-observable/component.json +7 -3
  43. data/vendor/components/indefinido-observable/components/chaijs-chai/component.json +46 -0
  44. data/vendor/components/indefinido-observable/components/chaijs-chai/index.js +1 -0
  45. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/assertion.js +132 -0
  46. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/core/assertions.js +1270 -0
  47. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/error.js +60 -0
  48. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/assert.js +1060 -0
  49. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/expect.js +12 -0
  50. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/interface/should.js +76 -0
  51. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +94 -0
  52. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addMethod.js +37 -0
  53. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/addProperty.js +40 -0
  54. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/eql.js +124 -0
  55. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/flag.js +32 -0
  56. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getActual.js +19 -0
  57. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +25 -0
  58. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getMessage.js +49 -0
  59. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getName.js +20 -0
  60. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getPathValue.js +102 -0
  61. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/getProperties.js +35 -0
  62. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/index.js +108 -0
  63. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/inspect.js +316 -0
  64. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/objDisplay.js +48 -0
  65. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +51 -0
  66. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +54 -0
  67. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/test.js +26 -0
  68. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/transferFlags.js +44 -0
  69. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai/utils/type.js +45 -0
  70. data/vendor/components/indefinido-observable/components/chaijs-chai/lib/chai.js +79 -0
  71. data/vendor/components/indefinido-observable/components/cjohansen-sinon/sinon.js +4290 -0
  72. data/vendor/components/indefinido-observable/components/component-jquery/component.json +14 -0
  73. data/vendor/components/indefinido-observable/components/component-jquery/index.js +9601 -0
  74. data/vendor/components/indefinido-observable/components/kapit-observe-shim/component.json +11 -0
  75. data/vendor/components/indefinido-observable/components/kapit-observe-utils/component.json +13 -0
  76. data/vendor/components/indefinido-observable/karma.conf.js +92 -0
  77. data/vendor/components/indefinido-observable/lib/observable.js +9 -19
  78. data/vendor/components/indefinido-observable/spec/legacy/observable_spec.js +126 -0
  79. data/vendor/components/indefinido-observable/spec/observable_spec.js +92 -0
  80. data/vendor/components/indefinido-observable/spec/spec_helper.js +8 -0
  81. data/vendor/components/indefinido-observable/spec/vendor/accessors_spec.js +63 -0
  82. data/vendor/components/indefinido-observable/src/lib/adapters/rivets.js.coffee +15 -0
  83. data/vendor/components/indefinido-observable/src/spec/legacy/observable_spec.coffee +132 -0
  84. data/vendor/components/indefinido-observable/src/spec/observable_spec.coffee +85 -0
  85. data/vendor/components/indefinido-observable/src/spec/spec_helper.coffee +5 -0
  86. data/vendor/components/indefinido-observable/src/spec/vendor/accessors_spec.coffee +59 -0
  87. data/vendor/components/indefinido-observable/vendor/spec/boot.js +104 -0
  88. data/vendor/components/indefinido-observable/vendor/spec/jasmine.js +2054 -0
  89. metadata +60 -8
  90. data/lib/assets/javascripts/aura/extensions/domain.js.coffee +0 -55
  91. data/lib/assets/javascripts/aura/extensions/stamps.js.coffee +0 -35
  92. data/lib/assets/javascripts/aura/extensions/widget/composable.js.coffee +0 -135
  93. data/lib/assets/javascripts/aura/extensions/widget/flowable.js.coffee +0 -65
  94. data/lib/assets/javascripts/widgets/attachable/main.js.coffee +0 -77
  95. /data/{lib/assets/javascripts/aura/extensions/stamps → vendor/assets/javascripts/stampit}/stampit.js +0 -0
@@ -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,124 @@
1
+ // This is (almost) directly from Node.js assert
2
+ // https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/assert.js
3
+
4
+ module.exports = _deepEqual;
5
+
6
+ var getEnumerableProperties = require('./getEnumerableProperties');
7
+
8
+ // for the browser
9
+ var Buffer;
10
+ try {
11
+ Buffer = require('buffer').Buffer;
12
+ } catch (ex) {
13
+ Buffer = {
14
+ isBuffer: function () { return false; }
15
+ };
16
+ }
17
+
18
+ function _deepEqual(actual, expected, memos) {
19
+
20
+ // 7.1. All identical values are equivalent, as determined by ===.
21
+ if (actual === expected) {
22
+ return true;
23
+
24
+ } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {
25
+ if (actual.length != expected.length) return false;
26
+
27
+ for (var i = 0; i < actual.length; i++) {
28
+ if (actual[i] !== expected[i]) return false;
29
+ }
30
+
31
+ return true;
32
+
33
+ // 7.2. If the expected value is a Date object, the actual value is
34
+ // equivalent if it is also a Date object that refers to the same time.
35
+ } else if (actual instanceof Date && expected instanceof Date) {
36
+ return actual.getTime() === expected.getTime();
37
+
38
+ // 7.3. Other pairs that do not both pass typeof value == 'object',
39
+ // equivalence is determined by ==.
40
+ } else if (typeof actual != 'object' && typeof expected != 'object') {
41
+ return actual === expected;
42
+
43
+ // 7.4. For all other Object pairs, including Array objects, equivalence is
44
+ // determined by having the same number of owned properties (as verified
45
+ // with Object.prototype.hasOwnProperty.call), the same set of keys
46
+ // (although not necessarily the same order), equivalent values for every
47
+ // corresponding key, and an identical 'prototype' property. Note: this
48
+ // accounts for both named and indexed properties on Arrays.
49
+ } else {
50
+ return objEquiv(actual, expected, memos);
51
+ }
52
+ }
53
+
54
+ function isUndefinedOrNull(value) {
55
+ return value === null || value === undefined;
56
+ }
57
+
58
+ function isArguments(object) {
59
+ return Object.prototype.toString.call(object) == '[object Arguments]';
60
+ }
61
+
62
+ function objEquiv(a, b, memos) {
63
+ if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
64
+ return false;
65
+
66
+ // an identical 'prototype' property.
67
+ if (a.prototype !== b.prototype) return false;
68
+
69
+ // check if we have already compared a and b
70
+ var i;
71
+ if (memos) {
72
+ for(i = 0; i < memos.length; i++) {
73
+ if ((memos[i][0] === a && memos[i][1] === b) ||
74
+ (memos[i][0] === b && memos[i][1] === a))
75
+ return true;
76
+ }
77
+ } else {
78
+ memos = [];
79
+ }
80
+
81
+ //~~~I've managed to break Object.keys through screwy arguments passing.
82
+ // Converting to array solves the problem.
83
+ if (isArguments(a)) {
84
+ if (!isArguments(b)) {
85
+ return false;
86
+ }
87
+ a = pSlice.call(a);
88
+ b = pSlice.call(b);
89
+ return _deepEqual(a, b, memos);
90
+ }
91
+ try {
92
+ var ka = getEnumerableProperties(a),
93
+ kb = getEnumerableProperties(b),
94
+ key;
95
+ } catch (e) {//happens when one is a string literal and the other isn't
96
+ return false;
97
+ }
98
+
99
+ // having the same number of owned properties (keys incorporates
100
+ // hasOwnProperty)
101
+ if (ka.length != kb.length)
102
+ return false;
103
+
104
+ //the same set of keys (although not necessarily the same order),
105
+ ka.sort();
106
+ kb.sort();
107
+ //~~~cheap key test
108
+ for (i = ka.length - 1; i >= 0; i--) {
109
+ if (ka[i] != kb[i])
110
+ return false;
111
+ }
112
+
113
+ // remember objects we have compared to guard against circular references
114
+ memos.push([ a, b ]);
115
+
116
+ //equivalent values for every corresponding key, and
117
+ //~~~possibly expensive deep test
118
+ for (i = ka.length - 1; i >= 0; i--) {
119
+ key = ka[i];
120
+ if (!_deepEqual(a[key], b[key], memos)) return false;
121
+ }
122
+
123
+ return true;
124
+ }
@@ -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
+ * Messsage 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
+ };