hana 1.3.3 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Manifest.txt +3 -2
- data/Rakefile +0 -1
- data/lib/hana.rb +7 -2
- data/test/json-patch-tests/.editorconfig +10 -0
- data/test/json-patch-tests/.npmignore +2 -0
- data/test/json-patch-tests/package.json +15 -0
- data/test/json-patch-tests/tests.json +28 -2
- data/test/test_hana.rb +39 -0
- metadata +8 -8
- data/.autotest +0 -8
- data/CHANGELOG.rdoc +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 556063c84c12bf3c25887a6021dbe2231ab3f4a63ef142ad9497031c7fdb6f14
|
4
|
+
data.tar.gz: 41a7f89c78c4cec3c97c5e8a1f9e409e3a7f6b7edc84ac8f21c7b794fce665f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6922f6fccc85b67181b4d262df950bbb76df8ace31be13acd1ad943aae40b3ab2f936a41af2e18cf546345409d51236c8a74a8a7be6bc05ec6a14c5456e9442b
|
7
|
+
data.tar.gz: 15c8575ff781dfe4dbb01bc77f80383d4a216a69d8e0282c64175837da52e29d5b92d88bb8ad0a891159ce33c2b9185d895337410400a8038650e623f0931c49
|
data/Manifest.txt
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
.autotest
|
2
|
-
CHANGELOG.rdoc
|
3
1
|
Manifest.txt
|
4
2
|
README.md
|
5
3
|
Rakefile
|
6
4
|
lib/hana.rb
|
7
5
|
test/helper.rb
|
6
|
+
test/json-patch-tests/.editorconfig
|
7
|
+
test/json-patch-tests/.npmignore
|
8
8
|
test/json-patch-tests/README.md
|
9
|
+
test/json-patch-tests/package.json
|
9
10
|
test/json-patch-tests/spec_tests.json
|
10
11
|
test/json-patch-tests/tests.json
|
11
12
|
test/mine.json
|
data/Rakefile
CHANGED
@@ -12,7 +12,6 @@ Hoe.spec 'hana' do
|
|
12
12
|
developer('Aaron Patterson', 'aaron@tenderlovemaking.com')
|
13
13
|
license 'MIT'
|
14
14
|
self.readme_file = 'README.md'
|
15
|
-
self.history_file = 'CHANGELOG.rdoc'
|
16
15
|
self.extra_rdoc_files = FileList['*.rdoc']
|
17
16
|
extra_dev_deps << ["minitest", "~> 5.0"]
|
18
17
|
end
|
data/lib/hana.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Hana
|
4
|
-
VERSION = '1.3.
|
4
|
+
VERSION = '1.3.4'
|
5
5
|
|
6
6
|
class Pointer
|
7
7
|
include Enumerable
|
@@ -100,7 +100,11 @@ module Hana
|
|
100
100
|
if key
|
101
101
|
add_op dest, key, obj
|
102
102
|
else
|
103
|
-
|
103
|
+
if doc.equal? dest
|
104
|
+
doc = obj
|
105
|
+
else
|
106
|
+
dest.replace obj
|
107
|
+
end
|
104
108
|
end
|
105
109
|
doc
|
106
110
|
end
|
@@ -157,6 +161,7 @@ module Hana
|
|
157
161
|
raise Patch::IndexError unless key =~ /\A\d+\Z/
|
158
162
|
obj[key.to_i] = ins.fetch VALUE
|
159
163
|
else
|
164
|
+
raise Patch::MissingTargetException unless obj
|
160
165
|
obj[key] = ins.fetch VALUE
|
161
166
|
end
|
162
167
|
doc
|
@@ -0,0 +1,15 @@
|
|
1
|
+
{
|
2
|
+
"name": "json-patch-test-suite",
|
3
|
+
"version": "1.1.0",
|
4
|
+
"description": "JSON Patch RFC 6902 test suite",
|
5
|
+
"repository": "github:json-patch/json-patch-tests",
|
6
|
+
"homepage": "https://github.com/json-patch/json-patch-tests",
|
7
|
+
"bugs": "https://github.com/json-patch/json-patch-tests/issues",
|
8
|
+
"keywords": [
|
9
|
+
"JSON",
|
10
|
+
"Patch",
|
11
|
+
"test",
|
12
|
+
"suite"
|
13
|
+
],
|
14
|
+
"license": "Apache-2.0"
|
15
|
+
}
|
@@ -55,6 +55,21 @@
|
|
55
55
|
"expected": "bar",
|
56
56
|
"disabled": true },
|
57
57
|
|
58
|
+
{ "comment": "replace object document with array document?",
|
59
|
+
"doc": {},
|
60
|
+
"patch": [{"op": "add", "path": "", "value": []}],
|
61
|
+
"expected": [] },
|
62
|
+
|
63
|
+
{ "comment": "replace array document with object document?",
|
64
|
+
"doc": [],
|
65
|
+
"patch": [{"op": "add", "path": "", "value": {}}],
|
66
|
+
"expected": {} },
|
67
|
+
|
68
|
+
{ "comment": "append to root array document?",
|
69
|
+
"doc": [],
|
70
|
+
"patch": [{"op": "add", "path": "/-", "value": "hi"}],
|
71
|
+
"expected": ["hi"] },
|
72
|
+
|
58
73
|
{ "comment": "Add, / target",
|
59
74
|
"doc": {},
|
60
75
|
"patch": [ {"op": "add", "path": "/", "value":1 } ],
|
@@ -187,6 +202,11 @@
|
|
187
202
|
"patch": [{"op": "replace", "path": "", "value": {"baz": "qux"}}],
|
188
203
|
"expected": {"baz": "qux"} },
|
189
204
|
|
205
|
+
{ "comment": "test replace with missing parent key should fail",
|
206
|
+
"doc": {"bar": "baz"},
|
207
|
+
"patch": [{"op": "replace", "path": "/foo/bar", "value": false}],
|
208
|
+
"error": "replace op should fail with missing parent key" },
|
209
|
+
|
190
210
|
{ "comment": "spurious patch properties",
|
191
211
|
"doc": {"foo": 1},
|
192
212
|
"patch": [{"op": "test", "path": "/foo", "value": 1, "spurious": 1}],
|
@@ -394,7 +414,7 @@
|
|
394
414
|
"doc": ["foo", "bar"],
|
395
415
|
"patch": [{"op": "test", "path": "/01", "value": "bar"}],
|
396
416
|
"error": "test op should reject the array value, it has leading zeros" },
|
397
|
-
|
417
|
+
|
398
418
|
{ "comment": "Removing nonexistent field",
|
399
419
|
"doc": {"foo" : "bar"},
|
400
420
|
"patch": [{"op": "remove", "path": "/baz"}],
|
@@ -403,6 +423,12 @@
|
|
403
423
|
{ "comment": "Removing nonexistent index",
|
404
424
|
"doc": ["foo", "bar"],
|
405
425
|
"patch": [{"op": "remove", "path": "/2"}],
|
406
|
-
"error": "removing a nonexistent index should fail" }
|
426
|
+
"error": "removing a nonexistent index should fail" },
|
427
|
+
|
428
|
+
{ "comment": "Patch with different capitalisation than doc",
|
429
|
+
"doc": {"foo":"bar"},
|
430
|
+
"patch": [{"op": "add", "path": "/FOO", "value": "BAR"}],
|
431
|
+
"expected": {"foo": "bar", "FOO": "BAR"}
|
432
|
+
}
|
407
433
|
|
408
434
|
]
|
data/test/test_hana.rb
CHANGED
@@ -69,4 +69,43 @@ class TestHana < Hana::TestCase
|
|
69
69
|
pointer = Hana::Pointer.new '/foo/bar/baz'
|
70
70
|
assert_nil pointer.eval('foo' => nil)
|
71
71
|
end
|
72
|
+
|
73
|
+
def test_remove_missing_object_key
|
74
|
+
patch = Hana::Patch.new [
|
75
|
+
{ 'op' => 'remove', 'path' => '/missing_key' }
|
76
|
+
]
|
77
|
+
assert_raises(Hana::Patch::IndexError) do
|
78
|
+
patch.apply('foo' => 'bar')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_remove_missing_array_index
|
83
|
+
patch = Hana::Patch.new [
|
84
|
+
{ 'op' => 'remove', 'path' => '/1' }
|
85
|
+
]
|
86
|
+
assert_raises(Hana::Patch::OutOfBoundsException) do
|
87
|
+
patch.apply([0])
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_remove_missing_object_key_in_array
|
92
|
+
patch = Hana::Patch.new [
|
93
|
+
{ 'op' => 'remove', 'path' => '/1/baz' }
|
94
|
+
]
|
95
|
+
assert_raises(Hana::Patch::IndexError) do
|
96
|
+
patch.apply([
|
97
|
+
{ 'foo' => 'bar' },
|
98
|
+
{ 'foo' => 'bar' }
|
99
|
+
])
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_replace_missing_key
|
104
|
+
patch = Hana::Patch.new [
|
105
|
+
{ 'op' => 'replace', 'path' => '/missing_key/field', 'value' => 'asdf' }
|
106
|
+
]
|
107
|
+
assert_raises(Hana::Patch::MissingTargetException) do
|
108
|
+
patch.apply('foo' => 'bar')
|
109
|
+
end
|
110
|
+
end
|
72
111
|
end
|
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.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Patterson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-17 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.
|
19
|
+
version: '5.11'
|
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.
|
26
|
+
version: '5.11'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,18 +58,18 @@ email:
|
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files:
|
61
|
-
- CHANGELOG.rdoc
|
62
61
|
- Manifest.txt
|
63
62
|
- README.md
|
64
63
|
files:
|
65
|
-
- ".autotest"
|
66
|
-
- CHANGELOG.rdoc
|
67
64
|
- Manifest.txt
|
68
65
|
- README.md
|
69
66
|
- Rakefile
|
70
67
|
- lib/hana.rb
|
71
68
|
- test/helper.rb
|
69
|
+
- test/json-patch-tests/.editorconfig
|
70
|
+
- test/json-patch-tests/.npmignore
|
72
71
|
- test/json-patch-tests/README.md
|
72
|
+
- test/json-patch-tests/package.json
|
73
73
|
- test/json-patch-tests/spec_tests.json
|
74
74
|
- test/json-patch-tests/tests.json
|
75
75
|
- test/mine.json
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project:
|
100
|
-
rubygems_version: 2.6
|
100
|
+
rubygems_version: 2.7.6
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: Implementation of [JSON Patch][1] and [JSON Pointer][2] RFC.
|
data/.autotest
DELETED
data/CHANGELOG.rdoc
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
Wed May 22 19:28:10 2013 Aaron Patterson <aaron@tenderlovemaking.com>
|
2
|
-
|
3
|
-
* All IETF compliant
|
4
|
-
|
5
|
-
Fri Sep 7 18:54:17 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
6
|
-
|
7
|
-
* Bumping the version.
|
8
|
-
|
9
|
-
Fri Sep 7 18:53:16 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
10
|
-
|
11
|
-
* validate commands an raise an exception Just In Case
|
12
|
-
|