jsonpathv2 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ROADMAP.md +3 -0
- data/lib/jsonpathv2/enumerable.rb +10 -5
- data/lib/jsonpathv2/version.rb +1 -1
- 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: f23e4231290ad706db184bb34ab670e849963295
|
4
|
+
data.tar.gz: c8855a86cff8cc2fa40054f782bc006bd7b42f3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da31e03333972e227a8ec457c03cba2fe35efb714245ee8427f479f8414e0e9dad11973ea309d2895e598f8c75e1833fce5c5f6d8c41903c36bbfa1de0418ba6
|
7
|
+
data.tar.gz: c3750c04010e7fd14e78e8b9b88cbca3cd9e057b71a181692519854551b634786a78813f4e51695788ca9c933e2814d0901eff86facc54019d4b32c30f57ba46
|
data/ROADMAP.md
CHANGED
@@ -29,7 +29,7 @@ class JsonPath
|
|
29
29
|
handle_wildecard(node, expr, context, key, pos, &blk)
|
30
30
|
else
|
31
31
|
if pos == (@path.size - 1) && node && allow_eval?
|
32
|
-
yield_value(blk, context, key) if
|
32
|
+
yield_value(blk, context, key) if instance_eval("node #{@path[pos]}")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -116,9 +116,13 @@ class JsonPath
|
|
116
116
|
return nil unless allow_eval? && @_current_node
|
117
117
|
|
118
118
|
identifiers = /@?(\.(\w+))+/.match(exp)
|
119
|
+
# puts JsonPath.on(@_current_node, "#{identifiers}") unless identifiers.nil? ||
|
120
|
+
# @_current_node
|
121
|
+
# .methods
|
122
|
+
# .include?(identifiers[2].to_sym)
|
119
123
|
|
120
|
-
|
121
|
-
|
124
|
+
unless identifiers.nil? ||
|
125
|
+
@_current_node.methods.include?(identifiers[2].to_sym)
|
122
126
|
|
123
127
|
exp_to_eval = exp.dup
|
124
128
|
exp_to_eval[identifiers[0]] = identifiers[0].split('.').map do |el|
|
@@ -126,12 +130,13 @@ class JsonPath
|
|
126
130
|
end.join
|
127
131
|
|
128
132
|
begin
|
129
|
-
return
|
133
|
+
return instance_eval(exp_to_eval)
|
130
134
|
# if eval failed because of bad arguments or missing methods
|
131
135
|
rescue StandardError
|
132
136
|
return default
|
133
137
|
end
|
134
138
|
end
|
139
|
+
|
135
140
|
# otherwise eval as is
|
136
141
|
# TODO: this eval is wrong, because hash accessor could be nil and nil
|
137
142
|
# cannot be compared with anything, for instance,
|
@@ -139,7 +144,7 @@ class JsonPath
|
|
139
144
|
# node, but it's only in several nodes I wrapped this eval into rescue
|
140
145
|
# returning false when error, but this eval should be refactored.
|
141
146
|
begin
|
142
|
-
|
147
|
+
instance_eval(exp.gsub(/@/, '@_current_node'))
|
143
148
|
rescue
|
144
149
|
false
|
145
150
|
end
|
data/lib/jsonpathv2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonpathv2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gergely Brautigam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|