jsonpath 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jsonpath/enumerable.rb +7 -2
- data/lib/jsonpath/version.rb +1 -1
- data/test/test_jsonpath.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbcb83c2762c708aa6f7ed1bff44def4ef4a6b46
|
4
|
+
data.tar.gz: ec7e54dd7bde48f57797666fa764d41573a8b6b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a83ff1f0c946ae83ee34a1c9852cc6c05651b70c06c211ae34285a82615ddab21195a62db8a30d747b3ac61b0624f7817556a557d39f39865871e3e69da0308
|
7
|
+
data.tar.gz: 60e9ffe8463f7a14ed64f741643b9f60444e6c88a8056862f5beb2a7d65539a063a3f8af2724782d74ce99f3b195f64bafaad91f78536b572470eeb02e776f8b
|
data/lib/jsonpath/enumerable.rb
CHANGED
@@ -84,13 +84,18 @@ class JsonPath
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def yield_value(blk, context, key)
|
87
|
+
key = Integer(key) rescue key if key
|
87
88
|
case @mode
|
88
89
|
when nil
|
89
90
|
blk.call(key ? context[key] : context)
|
90
91
|
when :compact
|
91
|
-
|
92
|
+
if key && context[key].nil?
|
93
|
+
key.is_a?(Integer) ? context.delete_at(key) : context.delete(key)
|
94
|
+
end
|
92
95
|
when :delete
|
93
|
-
|
96
|
+
if key
|
97
|
+
key.is_a?(Integer) ? context.delete_at(key) : context.delete(key)
|
98
|
+
end
|
94
99
|
when :substitute
|
95
100
|
if key
|
96
101
|
context[key] = blk.call(context[key])
|
data/lib/jsonpath/version.rb
CHANGED
data/test/test_jsonpath.rb
CHANGED
@@ -170,6 +170,13 @@ class TestJsonpath < MiniTest::Unit::TestCase
|
|
170
170
|
assert_equal({ 'you' => nil }, h)
|
171
171
|
end
|
172
172
|
|
173
|
+
def test_delete_for_array
|
174
|
+
before = JsonPath.on(@object, '$..store.book[1]')
|
175
|
+
JsonPath.for(@object).delete!('$..store.book[0]')
|
176
|
+
after = JsonPath.on(@object, '$..store.book[0]')
|
177
|
+
assert_equal(after, before, 'Before is the second element. After should have been equal to the next element after delete.')
|
178
|
+
end
|
179
|
+
|
173
180
|
def test_at_sign_in_json_element
|
174
181
|
data =
|
175
182
|
{ '@colors' =>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonpath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Hull
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-08-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|