seapig-server 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +36 -0
  4. data/Rakefile +37 -0
  5. data/bin/seapig-server +289 -0
  6. data/lib/seapig-server.rb +4 -0
  7. data/lib/seapig/version.rb +3 -0
  8. data/test/dummy/README.rdoc +28 -0
  9. data/test/dummy/Rakefile +6 -0
  10. data/test/dummy/app/assets/javascripts/application.js +15 -0
  11. data/test/dummy/app/assets/javascripts/json-patch.js +392 -0
  12. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  13. data/test/dummy/app/controllers/application_controller.rb +9 -0
  14. data/test/dummy/app/helpers/application_helper.rb +2 -0
  15. data/test/dummy/app/views/application/index.html.slim +10 -0
  16. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  17. data/test/dummy/bin/bundle +3 -0
  18. data/test/dummy/bin/rails +4 -0
  19. data/test/dummy/bin/rake +4 -0
  20. data/test/dummy/bin/setup +29 -0
  21. data/test/dummy/config.ru +4 -0
  22. data/test/dummy/config/application.rb +26 -0
  23. data/test/dummy/config/boot.rb +5 -0
  24. data/test/dummy/config/database.yml +85 -0
  25. data/test/dummy/config/environment.rb +5 -0
  26. data/test/dummy/config/environments/development.rb +41 -0
  27. data/test/dummy/config/environments/production.rb +79 -0
  28. data/test/dummy/config/environments/test.rb +42 -0
  29. data/test/dummy/config/initializers/assets.rb +11 -0
  30. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  31. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  32. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  33. data/test/dummy/config/initializers/inflections.rb +16 -0
  34. data/test/dummy/config/initializers/mime_types.rb +4 -0
  35. data/test/dummy/config/initializers/session_store.rb +3 -0
  36. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  37. data/test/dummy/config/locales/en.yml +23 -0
  38. data/test/dummy/config/routes.rb +56 -0
  39. data/test/dummy/config/secrets.yml +22 -0
  40. data/test/dummy/lib/seapigs/random.rb +14 -0
  41. data/test/dummy/log/development.log +1665 -0
  42. data/test/dummy/public/404.html +67 -0
  43. data/test/dummy/public/422.html +67 -0
  44. data/test/dummy/public/500.html +66 -0
  45. data/test/dummy/public/favicon.ico +0 -0
  46. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/-o-ZYYvENmbyGnbDFt6qAW7obI2QzsO9rM9EA7XlUHg.cache +0 -0
  47. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/1PVg-zJVu7--eXgp92_OEGf9YMjumXrwhnEbNQdV4h8.cache +1 -0
  48. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/2R9FCEwuVplMI7I5GoTBtw2Er_ap6H5s2otDK-m5XCk.cache +0 -0
  49. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/3eEw6ayC9zVKEVm7sgtqdiFFsi-0w4VyeWxR-hk72xg.cache +0 -0
  50. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -0
  51. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/66l7LMqenzmlIoboeeCMFEZ6J_6zFdXmqNs-gu79P94.cache +1 -0
  52. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/6vXjezhMg67rV3BDCPOxLeOVbgCHn0aDwBXCA-N7_To.cache +2 -0
  53. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/7SWrjVR_xhTD9BCS4ifXzZIDn6dp3guSJjF8v5pYDRc.cache +1 -0
  54. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/98GLSy3KoIvHccw_zbxLg3FpmPEUKmGUr5oL7YZmvOU.cache +127 -0
  55. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/9Kel6H2jL5qJlsGHIcYRbxGaV-rMj_teA3CD1eaUVmk.cache +2 -0
  56. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/9T1WawqT-S8RLLgLI4J-o5mcGyy-wwU2mYMBwTuTl4o.cache +0 -0
  57. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/BXgyeZH3I-u535wy4F0jP3wmfV8m8WIWtXqHJKdBC2Q.cache +0 -0
  58. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/BsW5E247kS632hUZ5-NHcjkfprM3AwsB8dksndomUAY.cache +1 -0
  59. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/CW1ly2CbYhIQ3PoOCrGTUOxS8a03kI-4spp4REHx6mc.cache +0 -0
  60. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/Duqe6Cf2ThStcjIWL29RZnPilo1v6Vi7p86VOEBKqCs.cache +0 -0
  61. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/ETKdv5blZ86XWjAQcmxAQq2wK6RT9QvGqd7uV7DK1Iw.cache +2 -0
  62. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/HCc1doOYzZaBpAX7ozNMpo1ErZFli_aaKFQ73oRipH0.cache +2 -0
  63. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/KS-8mb2c29Zj9YWoyTAojF-sqg-aKMYQr6FkxGuoBWQ.cache +0 -0
  64. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/Lgka3bEq-I8Y6xz-LVIYNVeNIWkmW1NKDnOHOkYcxtE.cache +1 -0
  65. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -0
  66. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/PgVoTat4a0VNolKPJS5RtDX7XcbAGbsqhquIWgWBBWE.cache +0 -0
  67. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/Tq5PhgpHymowY-e-a3airP7Q2OwxNuNC0792hdlAJRc.cache +1 -0
  68. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/VegRto_fFjOSBWQRgNRnnOiV3yByrpUI9b5IEhRvrDI.cache +1 -0
  69. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/VqL7bJxBiq13xYePLO71Spa6RfD5dFCeRRLGYb5jEqw.cache +0 -0
  70. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/X5QxTUYFP4VOH_7p2Qh34msJtFA6fOnJ0mM7Zip7dRU.cache +1 -0
  71. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/_2P0GKBCbJ61e8RdTBx4rJr8TsUYKFJYd7N0ZhA7o6k.cache +0 -0
  72. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/_mxi_K1gl7n32DYq8bFfbWrIRQrU3QQiuukc63_UBb4.cache +1 -0
  73. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/a1-5JrPXbtVr0ytoeAR0GzDsG_rlYUHm_sKEC1VHrrM.cache +1 -0
  74. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/aShHx921rUO4rZzH4135LWkt4TSWfqhpQMN8JsV2OqE.cache +0 -0
  75. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/b9Ac87wpHRTGZL-mBacNdb343KQ1426WdjSu03OVlz8.cache +0 -0
  76. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/beCZt_nFEyk5iX6v4bgC3qrdFMgSM0IgrwxaBTFEFA0.cache +1 -0
  77. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/bkclf1HVUxdntd8cKLvWGX5Pq-E12kwCwakqLo8RoN4.cache +1 -0
  78. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/csrXH9BNqM8JCRjroMFCt2hluEvIvM0neY_ZQySl58A.cache +1 -0
  79. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/fsxRcZUqoELh6-D0RWowwDKHYmUkGzh5HMFuwMMWk1g.cache +1 -0
  80. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/h2XCtwcdt21JcAtjhfoOuIjifaMeMaYwPcFGnmNc2ng.cache +1 -0
  81. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +3 -0
  82. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/j3q-1jQzykD1sMeX9INl7jygCKtC0XJ8JkWkFQkL6qg.cache +2 -0
  83. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/j4VcbkSejSElTiJk3ehlEcJE9HRTG7T14-wVhUDocaA.cache +1 -0
  84. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/jU_8gMY9eZiN785s1lakKFjnK5ox1EA-Na1fKxuYcjs.cache +1 -0
  85. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
  86. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/q3UrpsuPTq0hMrkTWoYoYEZL4u05PdVc4L5NXKuFDgQ.cache +0 -0
  87. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/sX4-Kn9knBu7plHg7gUT-ryVktGvmZfacNm1cUysjWs.cache +1 -0
  88. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/umxcUEQeoCOqF0ZwXlNqJEOyT_vhMK8iGO4--jduIDU.cache +1 -0
  89. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/urzLHu3R3qKeFqygSDL0NVDcyw8BFEA6i9jFeweVZQ4.cache +1 -0
  90. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/vCljKmhe1Sy9j9TDIB9DrQRa8dYlkPg8nyvsZfqfCmw.cache +0 -0
  91. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/vn6FA8BrDkisPSH4VFlc7tgmkzpx1DsOtDp5C3cdaRU.cache +1 -0
  92. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/wtuO4JuGsyO8emVQL7t1bm1fvl6YzGfBHc3tJJ49uvs.cache +2 -0
  93. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/z9KVC85iQuroh2hLYTGZhgZHDlh7183qTlfed3Uhtnw.cache +0 -0
  94. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/znvRewDLwMSRAUjlQozzMBQ_IGWvw9fVVOh9aeaXxTA.cache +0 -0
  95. data/test/dummy/tmp/cache/assets/development/sprockets/v3.0/zxZcbwt4p6Q1Z7yZfuWYKTXjetmNZI8MgkKazd4PjoA.cache +0 -0
  96. data/test/integration/navigation_test.rb +8 -0
  97. data/test/seapig_test.rb +7 -0
  98. data/test/test_helper.rb +20 -0
  99. metadata +275 -0
@@ -0,0 +1,392 @@
1
+ /*!
2
+ * https://github.com/Starcounter-Jack/JSON-Patch
3
+ * json-patch-duplex.js version: 0.5.4
4
+ * (c) 2013 Joachim Wester
5
+ * MIT license
6
+ */
7
+ var __extends = this.__extends || function (d, b) {
8
+ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
9
+ function __() { this.constructor = d; }
10
+ __.prototype = b.prototype;
11
+ d.prototype = new __();
12
+ };
13
+ var OriginalError = Error;
14
+
15
+ var jsonpatch;
16
+ (function (jsonpatch) {
17
+ /* Do nothing if module is already defined.
18
+ Doesn't look nice, as we cannot simply put
19
+ `!jsonpatch &&` before this immediate function call
20
+ in TypeScript.
21
+ */
22
+ if (jsonpatch.apply) {
23
+ return;
24
+ }
25
+
26
+ var _objectKeys = (function () {
27
+ if (Object.keys)
28
+ return Object.keys;
29
+
30
+ return function (o) {
31
+ var keys = [];
32
+ for (var i in o) {
33
+ if (o.hasOwnProperty(i)) {
34
+ keys.push(i);
35
+ }
36
+ }
37
+ return keys;
38
+ };
39
+ })();
40
+
41
+ function _equals(a, b) {
42
+ switch (typeof a) {
43
+ case 'undefined':
44
+ case 'boolean':
45
+ case 'string':
46
+ case 'number':
47
+ return a === b;
48
+ case 'object':
49
+ if (a === null)
50
+ return b === null;
51
+ if (_isArray(a)) {
52
+ if (!_isArray(b) || a.length !== b.length)
53
+ return false;
54
+
55
+ for (var i = 0, l = a.length; i < l; i++)
56
+ if (!_equals(a[i], b[i]))
57
+ return false;
58
+
59
+ return true;
60
+ }
61
+
62
+ var bKeys = _objectKeys(b);
63
+ var bLength = bKeys.length;
64
+ if (_objectKeys(a).length !== bLength)
65
+ return false;
66
+
67
+ for (var i = 0; i < bLength; i++)
68
+ if (!_equals(a[i], b[i]))
69
+ return false;
70
+
71
+ return true;
72
+
73
+ default:
74
+ return false;
75
+ }
76
+ }
77
+
78
+ /* We use a Javascript hash to store each
79
+ function. Each hash entry (property) uses
80
+ the operation identifiers specified in rfc6902.
81
+ In this way, we can map each patch operation
82
+ to its dedicated function in efficient way.
83
+ */
84
+ /* The operations applicable to an object */
85
+ var objOps = {
86
+ add: function (obj, key) {
87
+ obj[key] = this.value;
88
+ return true;
89
+ },
90
+ remove: function (obj, key) {
91
+ delete obj[key];
92
+ return true;
93
+ },
94
+ replace: function (obj, key) {
95
+ obj[key] = this.value;
96
+ return true;
97
+ },
98
+ move: function (obj, key, tree) {
99
+ var temp = { op: "_get", path: this.from };
100
+ apply(tree, [temp]);
101
+ apply(tree, [
102
+ { op: "remove", path: this.from }
103
+ ]);
104
+ apply(tree, [
105
+ { op: "add", path: this.path, value: temp.value }
106
+ ]);
107
+ return true;
108
+ },
109
+ copy: function (obj, key, tree) {
110
+ var temp = { op: "_get", path: this.from };
111
+ apply(tree, [temp]);
112
+ apply(tree, [
113
+ { op: "add", path: this.path, value: temp.value }
114
+ ]);
115
+ return true;
116
+ },
117
+ test: function (obj, key) {
118
+ return _equals(obj[key], this.value);
119
+ },
120
+ _get: function (obj, key) {
121
+ this.value = obj[key];
122
+ }
123
+ };
124
+
125
+ /* The operations applicable to an array. Many are the same as for the object */
126
+ var arrOps = {
127
+ add: function (arr, i) {
128
+ arr.splice(i, 0, this.value);
129
+ return true;
130
+ },
131
+ remove: function (arr, i) {
132
+ arr.splice(i, 1);
133
+ return true;
134
+ },
135
+ replace: function (arr, i) {
136
+ arr[i] = this.value;
137
+ return true;
138
+ },
139
+ move: objOps.move,
140
+ copy: objOps.copy,
141
+ test: objOps.test,
142
+ _get: objOps._get
143
+ };
144
+
145
+ /* The operations applicable to object root. Many are the same as for the object */
146
+ var rootOps = {
147
+ add: function (obj) {
148
+ rootOps.remove.call(this, obj);
149
+ for (var key in this.value) {
150
+ if (this.value.hasOwnProperty(key)) {
151
+ obj[key] = this.value[key];
152
+ }
153
+ }
154
+ return true;
155
+ },
156
+ remove: function (obj) {
157
+ for (var key in obj) {
158
+ if (obj.hasOwnProperty(key)) {
159
+ objOps.remove.call(this, obj, key);
160
+ }
161
+ }
162
+ return true;
163
+ },
164
+ replace: function (obj) {
165
+ apply(obj, [
166
+ { op: "remove", path: this.path }
167
+ ]);
168
+ apply(obj, [
169
+ { op: "add", path: this.path, value: this.value }
170
+ ]);
171
+ return true;
172
+ },
173
+ move: objOps.move,
174
+ copy: objOps.copy,
175
+ test: function (obj) {
176
+ return (JSON.stringify(obj) === JSON.stringify(this.value));
177
+ },
178
+ _get: function (obj) {
179
+ this.value = obj;
180
+ }
181
+ };
182
+
183
+ var _isArray;
184
+ if (Array.isArray) {
185
+ _isArray = Array.isArray;
186
+ } else {
187
+ _isArray = function (obj) {
188
+ return obj.push && typeof obj.length === 'number';
189
+ };
190
+ }
191
+
192
+ //3x faster than cached /^\d+$/.test(str)
193
+ function isInteger(str) {
194
+ var i = 0;
195
+ var len = str.length;
196
+ var charCode;
197
+ while (i < len) {
198
+ charCode = str.charCodeAt(i);
199
+ if (charCode >= 48 && charCode <= 57) {
200
+ i++;
201
+ continue;
202
+ }
203
+ return false;
204
+ }
205
+ return true;
206
+ }
207
+
208
+ /// Apply a json-patch operation on an object tree
209
+ function apply(tree, patches, validate) {
210
+ var result = false, p = 0, plen = patches.length, patch, key;
211
+ while (p < plen) {
212
+ patch = patches[p];
213
+ p++;
214
+
215
+ // Find the object
216
+ var path = patch.path || "";
217
+ var keys = path.split('/');
218
+ var obj = tree;
219
+ var t = 1;
220
+ var len = keys.length;
221
+ var existingPathFragment = undefined;
222
+
223
+ while (true) {
224
+ key = keys[t];
225
+
226
+ if (validate) {
227
+ if (existingPathFragment === undefined) {
228
+ if (obj[key] === undefined) {
229
+ existingPathFragment = keys.slice(0, t).join('/');
230
+ } else if (t == len - 1) {
231
+ existingPathFragment = patch.path;
232
+ }
233
+ if (existingPathFragment !== undefined) {
234
+ this.validator(patch, p - 1, tree, existingPathFragment);
235
+ }
236
+ }
237
+ }
238
+
239
+ t++;
240
+ if (key === undefined) {
241
+ if (t >= len) {
242
+ result = rootOps[patch.op].call(patch, obj, key, tree); // Apply patch
243
+ break;
244
+ }
245
+ }
246
+ if (_isArray(obj)) {
247
+ if (key === '-') {
248
+ key = obj.length;
249
+ } else {
250
+ if (validate && !isInteger(key)) {
251
+ throw new JsonPatchError("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", p - 1, patch.path, patch);
252
+ }
253
+ key = parseInt(key, 10);
254
+ }
255
+ if (t >= len) {
256
+ if (validate && patch.op === "add" && key > obj.length) {
257
+ throw new JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", p - 1, patch.path, patch);
258
+ }
259
+ result = arrOps[patch.op].call(patch, obj, key, tree); // Apply patch
260
+ break;
261
+ }
262
+ } else {
263
+ if (key && key.indexOf('~') != -1)
264
+ key = key.replace(/~1/g, '/').replace(/~0/g, '~'); // escape chars
265
+ if (t >= len) {
266
+ result = objOps[patch.op].call(patch, obj, key, tree); // Apply patch
267
+ break;
268
+ }
269
+ }
270
+ obj = obj[key];
271
+ }
272
+ }
273
+ return result;
274
+ }
275
+ jsonpatch.apply = apply;
276
+
277
+ var JsonPatchError = (function (_super) {
278
+ __extends(JsonPatchError, _super);
279
+ function JsonPatchError(message, name, index, operation, tree) {
280
+ _super.call(this, message);
281
+ this.message = message;
282
+ this.name = name;
283
+ this.index = index;
284
+ this.operation = operation;
285
+ this.tree = tree;
286
+ }
287
+ return JsonPatchError;
288
+ })(OriginalError);
289
+ jsonpatch.JsonPatchError = JsonPatchError;
290
+
291
+ jsonpatch.Error = JsonPatchError;
292
+
293
+ /**
294
+ * Recursively checks whether an object has any undefined values inside.
295
+ */
296
+ function hasUndefined(obj) {
297
+ if (obj === undefined) {
298
+ return true;
299
+ }
300
+
301
+ if (typeof obj == "array" || typeof obj == "object") {
302
+ for (var i in obj) {
303
+ if (hasUndefined(obj[i])) {
304
+ return true;
305
+ }
306
+ }
307
+ }
308
+
309
+ return false;
310
+ }
311
+
312
+ /**
313
+ * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.
314
+ * @param {object} operation - operation object (patch)
315
+ * @param {number} index - index of operation in the sequence
316
+ * @param {object} [tree] - object where the operation is supposed to be applied
317
+ * @param {string} [existingPathFragment] - comes along with `tree`
318
+ */
319
+ function validator(operation, index, tree, existingPathFragment) {
320
+ if (typeof operation !== 'object' || operation === null || _isArray(operation)) {
321
+ throw new JsonPatchError('Operation is not an object', 'OPERATION_NOT_AN_OBJECT', index, operation, tree);
322
+ } else if (!objOps[operation.op]) {
323
+ throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, tree);
324
+ } else if (typeof operation.path !== 'string') {
325
+ throw new JsonPatchError('Operation `path` property is not a string', 'OPERATION_PATH_INVALID', index, operation, tree);
326
+ } else if ((operation.op === 'move' || operation.op === 'copy') && typeof operation.from !== 'string') {
327
+ throw new JsonPatchError('Operation `from` property is not present (applicable in `move` and `copy` operations)', 'OPERATION_FROM_REQUIRED', index, operation, tree);
328
+ } else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && operation.value === undefined) {
329
+ throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_REQUIRED', index, operation, tree);
330
+ } else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && hasUndefined(operation.value)) {
331
+ throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED', index, operation, tree);
332
+ } else if (tree) {
333
+ if (operation.op == "add") {
334
+ var pathLen = operation.path.split("/").length;
335
+ var existingPathLen = existingPathFragment.split("/").length;
336
+ if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {
337
+ throw new JsonPatchError('Cannot perform an `add` operation at the desired path', 'OPERATION_PATH_CANNOT_ADD', index, operation, tree);
338
+ }
339
+ } else if (operation.op === 'replace' || operation.op === 'remove' || operation.op === '_get') {
340
+ if (operation.path !== existingPathFragment) {
341
+ throw new JsonPatchError('Cannot perform the operation at a path that does not exist', 'OPERATION_PATH_UNRESOLVABLE', index, operation, tree);
342
+ }
343
+ } else if (operation.op === 'move' || operation.op === 'copy') {
344
+ var existingValue = { op: "_get", path: operation.from, value: undefined };
345
+ var error = jsonpatch.validate([existingValue], tree);
346
+ if (error && error.name === 'OPERATION_PATH_UNRESOLVABLE') {
347
+ throw new JsonPatchError('Cannot perform the operation from a path that does not exist', 'OPERATION_FROM_UNRESOLVABLE', index, operation, tree);
348
+ }
349
+ }
350
+ }
351
+ }
352
+ jsonpatch.validator = validator;
353
+
354
+ /**
355
+ * Validates a sequence of operations. If `tree` parameter is provided, the sequence is additionally validated against the object tree.
356
+ * If error is encountered, returns a JsonPatchError object
357
+ * @param sequence
358
+ * @param tree
359
+ * @returns {JsonPatchError|undefined}
360
+ */
361
+ function validate(sequence, tree) {
362
+ try {
363
+ if (!_isArray(sequence)) {
364
+ throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');
365
+ }
366
+
367
+ if (tree) {
368
+ tree = JSON.parse(JSON.stringify(tree)); //clone tree so that we can safely try applying operations
369
+ apply.call(this, tree, sequence, true);
370
+ } else {
371
+ for (var i = 0; i < sequence.length; i++) {
372
+ this.validator(sequence[i], i);
373
+ }
374
+ }
375
+ } catch (e) {
376
+ if (e instanceof JsonPatchError) {
377
+ return e;
378
+ } else {
379
+ throw e;
380
+ }
381
+ }
382
+ }
383
+ jsonpatch.validate = validate;
384
+ })(jsonpatch || (jsonpatch = {}));
385
+
386
+ if (typeof exports !== "undefined") {
387
+ exports.apply = jsonpatch.apply;
388
+ exports.validate = jsonpatch.validate;
389
+ exports.validator = jsonpatch.validator;
390
+ exports.JsonPatchError = jsonpatch.JsonPatchError;
391
+ exports.Error = jsonpatch.Error;
392
+ }
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,9 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+
6
+ def index
7
+ end
8
+
9
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,10 @@
1
+ | Seapig object:
2
+ br
3
+ code#object-drop
4
+ | not loaded yet
5
+ javascript:
6
+ var server = new SeaPigServer('ws://localhost:3001/seapig');
7
+ var object = server.link('random-list');
8
+ object.onchange = function() {
9
+ document.getElementById('object-drop').innerHTML = JSON.stringify(object.object);
10
+ };
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>