hana 1.3.5 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8967fc878a6eb09d469a2020f6dcef6d78dbced59b3432a7627a1d82064d1cab
4
- data.tar.gz: fe88760ea18ff82c272b737e6e7c366dbecda53a1248b6307fc461d056433070
3
+ metadata.gz: 5c03b78248bd570dcbfafd16008862ef61e649362caba2718e14379cdb91a0fb
4
+ data.tar.gz: b06a607921faf55826ab2f975707eb7d109cbcf9199358bda1d995b4f284bf40
5
5
  SHA512:
6
- metadata.gz: 196a984b465565c19efd2e0fe6e08aa718b3dd846d36059242bfc36455deb9f0871aa66c32d892fe7b7b0bae80ed75c471a35dab6f9bc35af4c57a9253fb48e5
7
- data.tar.gz: b483189d57bd549d4c6072a9bd0adc84a480367fd20720e26c51dd40a48c96dedaf5aced42b64e478dd6ecf4c8554a147efaab9710bd7ee23e20d49871c32507
6
+ metadata.gz: 9af7c351c9328b51235961633b65e06ddba40c90d758774b26cf2430295a4260f61ca9b36094759d8e0a77c25a498cf0b92ba5e5323472104331b6c08a8d8729
7
+ data.tar.gz: 30785df502dd77244272c26d3709772d8c6ab8fc57d3e693bbe576befae60db6b3c82285d51d5e002453a176fb7c7a18a92fa1829887c484bf9007a29fc34151
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hana
4
- VERSION = '1.3.5'
4
+ VERSION = '1.3.6'
5
5
 
6
6
  class Pointer
7
7
  include Enumerable
@@ -233,7 +233,7 @@ module Hana
233
233
  raise Patch::OutOfBoundsException if key >= obj.length
234
234
  obj.delete_at key
235
235
  else
236
- raise Patch::IndexError unless obj.key? key
236
+ raise Patch::IndexError unless obj&.key? key
237
237
  obj.delete key
238
238
  end
239
239
  end
@@ -214,6 +214,7 @@
214
214
 
215
215
  { "doc": {"foo": null},
216
216
  "patch": [{"op": "test", "path": "/foo", "value": null}],
217
+ "expected": {"foo": null},
217
218
  "comment": "null value should be valid obj property" },
218
219
 
219
220
  { "doc": {"foo": null},
@@ -243,14 +244,17 @@
243
244
 
244
245
  { "doc": {"foo": {"foo": 1, "bar": 2}},
245
246
  "patch": [{"op": "test", "path": "/foo", "value": {"bar": 2, "foo": 1}}],
247
+ "expected": {"foo": {"foo": 1, "bar": 2}},
246
248
  "comment": "test should pass despite rearrangement" },
247
249
 
248
250
  { "doc": {"foo": [{"foo": 1, "bar": 2}]},
249
251
  "patch": [{"op": "test", "path": "/foo", "value": [{"bar": 2, "foo": 1}]}],
252
+ "expected": {"foo": [{"foo": 1, "bar": 2}]},
250
253
  "comment": "test should pass despite (nested) rearrangement" },
251
254
 
252
255
  { "doc": {"foo": {"bar": [1, 2, 5, 4]}},
253
256
  "patch": [{"op": "test", "path": "/foo", "value": {"bar": [1, 2, 5, 4]}}],
257
+ "expected": {"foo": {"bar": [1, 2, 5, 4]}},
254
258
  "comment": "test should pass - no error" },
255
259
 
256
260
  { "doc": {"foo": {"bar": [1, 2, 5, 4]}},
@@ -264,7 +268,8 @@
264
268
 
265
269
  { "comment": "Empty-string element",
266
270
  "doc": { "": 1 },
267
- "patch": [{"op": "test", "path": "/", "value": 1}] },
271
+ "patch": [{"op": "test", "path": "/", "value": 1}],
272
+ "expected": { "": 1 } },
268
273
 
269
274
  { "doc": {
270
275
  "foo": ["bar", "baz"],
@@ -288,8 +293,23 @@
288
293
  {"op": "test", "path": "/i\\j", "value": 5},
289
294
  {"op": "test", "path": "/k\"l", "value": 6},
290
295
  {"op": "test", "path": "/ ", "value": 7},
291
- {"op": "test", "path": "/m~0n", "value": 8}] },
292
-
296
+ {"op": "test", "path": "/m~0n", "value": 8}],
297
+ "expected": {
298
+ "": 0,
299
+ " ": 7,
300
+ "a/b": 1,
301
+ "c%d": 2,
302
+ "e^f": 3,
303
+ "foo": [
304
+ "bar",
305
+ "baz"
306
+ ],
307
+ "g|h": 4,
308
+ "i\\j": 5,
309
+ "k\"l": 6,
310
+ "m~n": 8
311
+ }
312
+ },
293
313
  { "comment": "Move to same location has no effect",
294
314
  "doc": {"foo": 1},
295
315
  "patch": [{"op": "move", "from": "/foo", "path": "/foo"}],
@@ -363,6 +383,21 @@
363
383
  "patch": [{"op": "add", "path": "/1e0", "value": "bar"}],
364
384
  "error": "add op shouldn't add to array with bad number" },
365
385
 
386
+ { "comment": "missing 'path' parameter",
387
+ "doc": {},
388
+ "patch": [ { "op": "add", "value": "bar" } ],
389
+ "error": "missing 'path' parameter" },
390
+
391
+ { "comment": "'path' parameter with null value",
392
+ "doc": {},
393
+ "patch": [ { "op": "add", "path": null, "value": "bar" } ],
394
+ "error": "null is not valid value for 'path'" },
395
+
396
+ { "comment": "invalid JSON Pointer token",
397
+ "doc": {},
398
+ "patch": [ { "op": "add", "path": "foo", "value": "bar" } ],
399
+ "error": "JSON Pointer should start with a slash" },
400
+
366
401
  { "comment": "missing 'value' parameter to add",
367
402
  "doc": [ 1 ],
368
403
  "patch": [ { "op": "add", "path": "/-" } ],
@@ -388,11 +423,21 @@
388
423
  "patch": [ { "op": "copy", "path": "/-" } ],
389
424
  "error": "missing 'from' parameter" },
390
425
 
426
+ { "comment": "missing from location to copy",
427
+ "doc": { "foo": 1 },
428
+ "patch": [ { "op": "copy", "from": "/bar", "path": "/foo" } ],
429
+ "error": "missing 'from' location" },
430
+
391
431
  { "comment": "missing from parameter to move",
392
432
  "doc": { "foo": 1 },
393
433
  "patch": [ { "op": "move", "path": "" } ],
394
434
  "error": "missing 'from' parameter" },
395
435
 
436
+ { "comment": "missing from location to move",
437
+ "doc": { "foo": 1 },
438
+ "patch": [ { "op": "move", "from": "/bar", "path": "/foo" } ],
439
+ "error": "missing 'from' location" },
440
+
396
441
  { "comment": "duplicate ops",
397
442
  "doc": { "foo": "bar" },
398
443
  "patch": [ { "op": "add", "path": "/baz", "value": "qux",
@@ -420,6 +465,11 @@
420
465
  "patch": [{"op": "remove", "path": "/baz"}],
421
466
  "error": "removing a nonexistent field should fail" },
422
467
 
468
+ { "comment": "Removing deep nonexistent path",
469
+ "doc": {"foo" : "bar"},
470
+ "patch": [{"op": "remove", "path": "/missing1/missing2"}],
471
+ "error": "removing a nonexistent field should fail" },
472
+
423
473
  { "comment": "Removing nonexistent index",
424
474
  "doc": ["foo", "bar"],
425
475
  "patch": [{"op": "remove", "path": "/2"}],
@@ -79,6 +79,15 @@ class TestHana < Hana::TestCase
79
79
  end
80
80
  end
81
81
 
82
+ def test_remove_deep_missing_path
83
+ patch = Hana::Patch.new [
84
+ { 'op' => 'remove', 'path' => '/missing_key1/missing_key2' }
85
+ ]
86
+ assert_raises(Hana::Patch::IndexError) do
87
+ patch.apply('foo' => 'bar')
88
+ end
89
+ end
90
+
82
91
  def test_remove_missing_array_index
83
92
  patch = Hana::Patch.new [
84
93
  { 'op' => 'remove', 'path' => '/1' }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-30 00:00:00.000000000 Z
11
+ date: 2020-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.11'
19
+ version: '5.14'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '5.11'
26
+ version: '5.14'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rdoc
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '3.17'
53
+ version: '3.22'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '3.17'
60
+ version: '3.22'
61
61
  description: Implementation of [JSON Patch][1] and [JSON Pointer][2] RFC.
62
62
  email:
63
63
  - aaron@tenderlovemaking.com
@@ -84,7 +84,8 @@ files:
84
84
  homepage: http://github.com/tenderlove/hana
85
85
  licenses:
86
86
  - MIT
87
- metadata: {}
87
+ metadata:
88
+ homepage_uri: http://github.com/tenderlove/hana
88
89
  post_install_message:
89
90
  rdoc_options:
90
91
  - "--main"
@@ -102,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  - !ruby/object:Gem::Version
103
104
  version: '0'
104
105
  requirements: []
105
- rubygems_version: 3.0.1
106
+ rubygems_version: 3.2.0.pre1
106
107
  signing_key:
107
108
  specification_version: 4
108
109
  summary: Implementation of [JSON Patch][1] and [JSON Pointer][2] RFC.