hana 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/Rakefile +1 -0
- data/lib/hana.rb +5 -2
- data/test/helper.rb +2 -1
- data/test/json-patch-tests/tests.json +38 -2
- data/test/test_hana.rb +5 -0
- metadata +8 -11
- data/.gemtest +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fb4c95fd3541788a19d1c4b9d7bd1931242191a
|
4
|
+
data.tar.gz: 83e628bf62efb6e476121837a710c0d64bfc7590
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b60dc61f8c64a99d6595b7b8e8192b2d1f658a47eab4a74bfca692edc4883dc25979b41bc4a68b3f1a5b02f69f832fdfa9ca744aea279ef7480d836b3ba0463
|
7
|
+
data.tar.gz: 52c58c0d9d5690a9f37c8e24621ae21dba3fd651566730c723c4603ab41c6b843da2f3b13eca22cf31a7bd0eb12e476b1f0c3f5d50a45d4eac57474b0e896480
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ process it, then emit as JSON again.
|
|
17
17
|
|
18
18
|
```ruby
|
19
19
|
patch = Hana::Patch.new [
|
20
|
-
{ 'add' => '/baz', 'value' => 'qux' }
|
20
|
+
{ 'op' => 'add', 'path' => '/baz', 'value' => 'qux' }
|
21
21
|
]
|
22
22
|
|
23
23
|
patch.apply('foo' => 'bar') # => {'baz' => 'qux', 'foo' => 'bar'}
|
@@ -35,7 +35,7 @@ patch.apply('foo' => 'bar') # => {'baz' => 'qux', 'foo' => 'bar'}
|
|
35
35
|
|
36
36
|
(The MIT License)
|
37
37
|
|
38
|
-
Copyright (c) 2012-
|
38
|
+
Copyright (c) 2012-2016 Aaron Patterson
|
39
39
|
|
40
40
|
Permission is hereby granted, free of charge, to any person obtaining
|
41
41
|
a copy of this software and associated documentation files (the
|
data/Rakefile
CHANGED
@@ -10,6 +10,7 @@ Hoe.plugin :git # `gem install hoe-git`
|
|
10
10
|
|
11
11
|
Hoe.spec 'hana' do
|
12
12
|
developer('Aaron Patterson', 'aaron@tenderlovemaking.com')
|
13
|
+
license 'MIT'
|
13
14
|
self.readme_file = 'README.md'
|
14
15
|
self.history_file = 'CHANGELOG.rdoc'
|
15
16
|
self.extra_rdoc_files = FileList['*.rdoc']
|
data/lib/hana.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Hana
|
2
|
-
VERSION = '1.3.
|
2
|
+
VERSION = '1.3.2'
|
3
3
|
|
4
4
|
class Pointer
|
5
5
|
include Enumerable
|
@@ -31,9 +31,12 @@ module Hana
|
|
31
31
|
def self.parse path
|
32
32
|
return [''] if path == '/'
|
33
33
|
|
34
|
-
path.sub(/^\//, '').split(/(?<!\^)\//).each { |part|
|
34
|
+
parts = path.sub(/^\//, '').split(/(?<!\^)\//).each { |part|
|
35
35
|
part.gsub!(/\^[\/^]|~[01]/) { |m| ESC[m] }
|
36
36
|
}
|
37
|
+
|
38
|
+
parts.push("") if path[-1] == '/'
|
39
|
+
parts
|
37
40
|
end
|
38
41
|
end
|
39
42
|
|
data/test/helper.rb
CHANGED
@@ -21,7 +21,7 @@ module Hana
|
|
21
21
|
patch = Hana::Patch.new patch
|
22
22
|
|
23
23
|
if test['error']
|
24
|
-
assert_raises(*ex(test['error'])) do
|
24
|
+
assert_raises(*ex(test['error']), test['error']) do
|
25
25
|
patch.apply doc
|
26
26
|
end
|
27
27
|
else
|
@@ -43,6 +43,7 @@ module Hana
|
|
43
43
|
def ex msg
|
44
44
|
case msg
|
45
45
|
when /Out of bounds/i then [Hana::Patch::OutOfBoundsException]
|
46
|
+
when /index is greater than/i then [Hana::Patch::OutOfBoundsException]
|
46
47
|
when /Object operation on array/ then
|
47
48
|
[Hana::Patch::ObjectOperationOnArrayException]
|
48
49
|
when /test op shouldn't get array element/ then
|
@@ -60,6 +60,11 @@
|
|
60
60
|
"patch": [ {"op": "add", "path": "/", "value":1 } ],
|
61
61
|
"expected": {"":1} },
|
62
62
|
|
63
|
+
{ "comment": "Add, /foo/ deep target (trailing slash)",
|
64
|
+
"doc": {"foo": {}},
|
65
|
+
"patch": [ {"op": "add", "path": "/foo/", "value":1 } ],
|
66
|
+
"expected": {"foo":{"": 1}} },
|
67
|
+
|
63
68
|
{ "comment": "Add composite value at top level",
|
64
69
|
"doc": {"foo": 1},
|
65
70
|
"patch": [{"op": "add", "path": "/bar", "value": [1, 2]}],
|
@@ -107,10 +112,16 @@
|
|
107
112
|
"patch": [{"op": "add", "path": "/0", "value": "bar"}],
|
108
113
|
"expected": ["bar", "foo", "sil"] },
|
109
114
|
|
110
|
-
{ "
|
115
|
+
{ "comment": "push item to array via last index + 1",
|
116
|
+
"doc": ["foo", "sil"],
|
111
117
|
"patch": [{"op":"add", "path": "/2", "value": "bar"}],
|
112
118
|
"expected": ["foo", "sil", "bar"] },
|
113
119
|
|
120
|
+
{ "comment": "add item to array at index > length should fail",
|
121
|
+
"doc": ["foo", "sil"],
|
122
|
+
"patch": [{"op":"add", "path": "/3", "value": "bar"}],
|
123
|
+
"error": "index is greater than number of items in array" },
|
124
|
+
|
114
125
|
{ "comment": "test against implementation-specific numeric parsing",
|
115
126
|
"doc": {"1e0": "foo"},
|
116
127
|
"patch": [{"op": "test", "path": "/1e0", "value": "foo"}],
|
@@ -183,7 +194,32 @@
|
|
183
194
|
|
184
195
|
{ "doc": {"foo": null},
|
185
196
|
"patch": [{"op": "test", "path": "/foo", "value": null}],
|
186
|
-
"comment": "null value should
|
197
|
+
"comment": "null value should be valid obj property" },
|
198
|
+
|
199
|
+
{ "doc": {"foo": null},
|
200
|
+
"patch": [{"op": "replace", "path": "/foo", "value": "truthy"}],
|
201
|
+
"expected": {"foo": "truthy"},
|
202
|
+
"comment": "null value should be valid obj property to be replaced with something truthy" },
|
203
|
+
|
204
|
+
{ "doc": {"foo": null},
|
205
|
+
"patch": [{"op": "move", "from": "/foo", "path": "/bar"}],
|
206
|
+
"expected": {"bar": null},
|
207
|
+
"comment": "null value should be valid obj property to be moved" },
|
208
|
+
|
209
|
+
{ "doc": {"foo": null},
|
210
|
+
"patch": [{"op": "copy", "from": "/foo", "path": "/bar"}],
|
211
|
+
"expected": {"foo": null, "bar": null},
|
212
|
+
"comment": "null value should be valid obj property to be copied" },
|
213
|
+
|
214
|
+
{ "doc": {"foo": null},
|
215
|
+
"patch": [{"op": "remove", "path": "/foo"}],
|
216
|
+
"expected": {},
|
217
|
+
"comment": "null value should be valid obj property to be removed" },
|
218
|
+
|
219
|
+
{ "doc": {"foo": "bar"},
|
220
|
+
"patch": [{"op": "replace", "path": "/foo", "value": null}],
|
221
|
+
"expected": {"foo": null},
|
222
|
+
"comment": "null value should still be valid obj property replace other value" },
|
187
223
|
|
188
224
|
{ "doc": {"foo": {"foo": 1, "bar": 2}},
|
189
225
|
"patch": [{"op": "test", "path": "/foo", "value": {"bar": 2, "foo": 1}}],
|
data/test/test_hana.rb
CHANGED
@@ -23,6 +23,11 @@ class TestHana < Hana::TestCase
|
|
23
23
|
assert_equal %w{ foo bar baz }, pointer.to_a
|
24
24
|
end
|
25
25
|
|
26
|
+
def test_split_with_trailing
|
27
|
+
pointer = Hana::Pointer.new '/foo/'
|
28
|
+
assert_equal ["foo", ""], pointer.to_a
|
29
|
+
end
|
30
|
+
|
26
31
|
def test_root
|
27
32
|
pointer = Hana::Pointer.new '/'
|
28
33
|
assert_equal [''], pointer.to_a
|
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.2
|
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: 2016-05-29 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.9'
|
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.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.15'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.15'
|
55
55
|
description: Implementation of [JSON Patch][1] and [JSON Pointer][2] RFC.
|
56
56
|
email:
|
57
57
|
- aaron@tenderlovemaking.com
|
@@ -63,7 +63,6 @@ extra_rdoc_files:
|
|
63
63
|
- README.md
|
64
64
|
files:
|
65
65
|
- ".autotest"
|
66
|
-
- ".gemtest"
|
67
66
|
- CHANGELOG.rdoc
|
68
67
|
- Manifest.txt
|
69
68
|
- README.md
|
@@ -98,10 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
97
|
version: '0'
|
99
98
|
requirements: []
|
100
99
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.4
|
100
|
+
rubygems_version: 2.6.4
|
102
101
|
signing_key:
|
103
102
|
specification_version: 4
|
104
103
|
summary: Implementation of [JSON Patch][1] and [JSON Pointer][2] RFC.
|
105
|
-
test_files:
|
106
|
-
- test/test_hana.rb
|
107
|
-
- test/test_ietf.rb
|
104
|
+
test_files: []
|
data/.gemtest
DELETED
File without changes
|